Skip to main content

auth_middleware

Function auth_middleware 

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

Axum middleware: resolve the tenant for a request and inject a TenantId into extensions.

  • require_auth = false (default): no auth check; injects the static default tenant so every downstream handler reads a uniform identity. Single-operator behavior is unchanged.
  • require_auth = true: reads the key from Authorization: Bearer <key> (or x-firstpass-key), verifies it against the configured tenant hashes, and injects the resolved tenant. A missing or invalid key returns 401 with an opaque body — no “unknown tenant” oracle.