Jwt
jwt
Summary
The jwt package is the HTTP surface of the Aetoskia Auth Service.
It declares the FastAPI router that exposes the authentication endpoints
(/register, /login, /me, /logout, /introspect) and the
get_current_user bearer-token dependency used to protect routes.
All user management, hashing, and token logic is delegated to the
:mod:jwtlib package (see the py-jwt project), while MongoDB persistence
comes from mongo_ops.
Quick start
Wire the router into an application:
Protect a route with the current user:
Notes
- The router mounts with an empty prefix and the
Authtag. get_current_userraises401withWWW-Authenticate: Bearerwhen the header is missing or the token cannot be validated.
Functions
get_current_user
async
Resolve the authenticated user from the bearer credentials.
Decodes the JWT via get_logged_in_user and returns the matching
public user profile. Any decoding, validity, or lookup failure produces the
same generic 401 response so that the endpoint does not leak token
internals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credentials |
HTTPAuthorizationCredentials | None
|
Bearer credentials extracted from the |
Depends(bearer_scheme)
|
Returns:
| Name | Type | Description |
|---|---|---|
PublicUser |
PublicUser
|
The public profile of the authenticated user. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
With status |