pub struct AuthConfig { /* private fields */ }Expand description
App-level authentication the router_with_* builders mount: an optional
Authorization: Bearer authenticator and an optional X-API-Key one, each
admitted only when set (ADR 0006). This is the config an apps/<name>-api
composition root hands the framework.
A bare Option<Arc<dyn Authenticator>> converts into an AuthConfig carrying
that bearer and no X-API-Key path, so every existing call-site keeps
working unchanged; reach the X-API-Key path with AuthConfig::with_api_key.
When neither authenticator is set (AuthConfig::none) no authn layer is
mounted at all — no caller is ever authenticated, so guarded routes answer
403 while public routes still serve.
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn none() -> Self
pub fn none() -> Self
No authentication: no caller is ever authenticated (guarded routes 403,
public routes still serve). The explicit, inference-friendly form of a bare
None authenticator.
Sourcepub fn bearer(bearer: Arc<dyn Authenticator>) -> Self
pub fn bearer(bearer: Arc<dyn Authenticator>) -> Self
Authenticate Authorization: Bearer against bearer; no X-API-Key path.
Sourcepub fn with_api_key(self, api_key: Arc<dyn Authenticator>) -> Self
pub fn with_api_key(self, api_key: Arc<dyn Authenticator>) -> Self
Also admit X-API-Key callers, authenticated against api_key (consulted
before the bearer path). Independent of whether a bearer is set, so an
AuthConfig::none().with_api_key(..) admits only X-API-Key callers.