Skip to main content

require_auth

Function require_auth 

Source
pub async fn require_auth(
    __arg0: State<Arc<AuthState>>,
    request: Request<Body>,
    next: Next,
) -> Result<Response<Body>, StatusCode>
Expand description

Axum middleware that validates the Authorization: Bearer <token> header against AuthState.

Case-insensitive prefix matching per RFC 7235. Constant-time token comparison via constant_time_eq.

§Errors

Returns StatusCode::UNAUTHORIZED if the token is missing or invalid.