📖 How to Use
All operations are plain async functions that work identically under
FastAPI, Flask, a CLI, or a script. Substitute your own repository to change
the persistence backend.
✍️ Register a user
Returns a PublicUser. Registration hashes the password before it reaches the
repository.
🔑 Log in
A successful login returns LoginResponse with an access token and the public
user. Failures raise AuthError subclasses; catch them and map to your HTTP
semantics (e.g. 401).
👤 Check the current user
Resolves the token subject to a PublicUser. Raises InvalidToken if the
token is missing, expired, or malformed, and UserNotFound if the subject no
longer exists.
🚪 Log out
Logout is a client-side signal: the returned LogoutResponse tells the caller
to discard the stored token. Stateless services should simply stop using the
token after logout.
🔎 Introspect a token
Verify an arbitrary token and get a structured verdict:
IntrospectResponse also provides result helpers used by the canonical
service for error mapping. For a pure boolean authorization check:
💉 Injecting a custom repository
Every operation accepts an optional repo. Provide your own
UserRepository-compatible object to swap storage:
📚 Read Next
- Framework Integration — FastAPI dependency wiring.
- Overview — architecture and models.