feat(api): complete /api/v1 auth via host callbacks#91
Merged
Conversation
Extend the general JSON API auth to the full Flutter contract: login, register, logout, refresh, me, and profile (validate already existed). All credential handling is delegated to host-app callbacks via a new Escalated.Api.HostAuth module — Escalated ships no password-hashing or session dependency. The host configures api_authenticator / api_registrar / api_token_validator / api_token_refresher / api_profile_updater / api_logout; unconfigured endpoints return 501.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the general
/api/v1to the Flutter auth contract, using the host-callback model (dependency-free — no password hashing or session store in the package).What
Escalated.Api.HostAuth— resolves and invokes host-configured callbacks:api_authenticator,api_registrar,api_token_validator,api_token_refresher,api_profile_updater,api_logout. Normalizes results to{:ok, map}/{:error, reason}(422) /:unauthorized(401) /:not_configured(501).AuthController— now serves the full contract:POST /auth/login,/auth/register,/auth/logout,/auth/refresh,GET /auth/me,PATCH /auth/profile(plus the pre-existingPOST /auth/validate, response shape preserved). Bearer token read from theAuthorizationheader./api/v1scope.Why host-callback
The host app owns user identity. Delegating keeps Escalated free of any auth dependency and avoids assuming a credential store — the package stays a drop-in across hosts.
Verification
mix formatclean;mix credo --strict— no issues on changed files (the CI lint gate).Escalated.Api.HostAuthTest— 7 tests (delegation, not-configured 501 path, error/unauthorized mapping, logout no-op + callback invocation).