Skip to main content

check_auth

Function check_auth 

Source
pub async fn check_auth(
    auth: &Option<Arc<AuthState>>,
    headers: &HeaderMap,
) -> Result<(), StatusCode>
Expand description

Check authentication for a protected endpoint.

Returns Ok(()) if auth is not configured (open mode), or if a valid token is present. Returns Err(StatusCode::UNAUTHORIZED) if auth is configured but no valid token is found.

Token sources (in order):

  1. Authorization: Bearer <token> header
  2. trustee_token=<token> cookie

Dev mode tokens use the format dev:email:name:username.