Skip to main content

auth_middleware

Function auth_middleware 

Source
pub async fn auth_middleware(
    __arg0: State<ResourceAuthState>,
    request: Request,
    next: Next,
) -> Response
Expand description

JWT authentication middleware

Validates JWT tokens via Ed25519 signature verification. Accepts Authorization: Bearer <token> and Authorization: DPoP <token>.

When the token carries a cnf.jkt claim (DPoP-bound token per RFC 9449), the Authorization: DPoP scheme MUST be used and a valid DPoP proof header MUST accompany the request — plain Bearer is rejected to prevent token replay after theft.

Revoked tokens (via POST /oauth/revoke) are rejected via JTI blocklist.

On success, inserts AuthenticatedUser into request extensions.