Skip to main content

auth_middleware

Function auth_middleware 

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

Axum middleware that validates Bearer tokens using a JwksCache.

On success the [ValidatedJwt] is inserted into request extensions so downstream handlers can extract it via Extension<ValidatedJwt>.

On failure the middleware short-circuits with 401 Unauthorized.