auth_middleware

Function auth_middleware 

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

Authentication middleware that validates Bearer tokens.

This middleware runs on every request and:

  1. Checks for an Authorization: Bearer <token> header
  2. Validates the token against the configured auth.api_token
  3. Sets AuthStatus::Admin if valid, AuthStatus::Public otherwise
  4. Inserts the status into request extensions for handlers to check