Expand description
The deny-by-default authentication middleware (ADR 0006).
It runs ahead of every route’s permission_guard,
turning an Authorization: Bearer <token> into the Principal the guard
and Scoped read:
- No credential header →
Principal::anonymousis inserted, so public routes (/health,/docs,/openapi.json) still serve and a guarded route’spermission_guardanswers403. - A present-but-invalid credential (bad signature, wrong
aud/iss, expired, unknown/revoked key, disallowed algorithm, or an empty/garbled header) →401RFC 9457Problemwith aWWW-Authenticateheader. The request never reaches the route.
Two credential sources, each with its own authenticator, run side by side
(ADR 0006): an opaque X-API-Key (checked first) and Authorization: Bearer.
With the mtls feature a third comes first (ADR 0047): the client
certificate the TLS handshake verified, mapped by a
CertificateAuthenticator (seiva_http::mtls). A request
carrying a verified certificate and a header credential is refused (401):
one request, one identity.
The Authenticator is the only authority on identity; the middleware never
trusts a header or body field to set the subject, tenant or permissions.
Structs§
- Auth
Config - App-level authentication the
router_with_*builders mount: an optionalAuthorization: Bearerauthenticator and an optionalX-API-Keyone, each admitted only when set (ADR 0006). This is the config anapps/<name>-apicomposition root hands the framework. - Authn
- The authenticators the
authnmiddleware consults: an optionalAuthorization: Bearerpath (JWT or static token) and an optional opaqueX-API-Keypath running alongside it (ADR 0006). At least one is set — the middleware is never mounted when both are absent (seeAuthConfig).