pub struct AuthLayer { /* private fields */ }Expand description
Tower layer that authenticates inbound requests and writes
AuthContext into request extensions.
Construct via AuthLayer::new and customize with the chained
with_* helpers.
Implementations§
Source§impl AuthLayer
impl AuthLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a bearer-only layer with neither a static token nor an auth
state. Such a layer always rejects requests with 401 — useful only
as a placeholder; real consumers immediately chain at least one of
Self::with_static_token / Self::with_auth_state.
Sourcepub fn from_state(auth_state: Arc<AuthState>) -> Self
pub fn from_state(auth_state: Arc<AuthState>) -> Self
Convenience constructor that pulls
static_token_scopes, login_path, and session_cookie_name
directly from the supplied AuthState’s config — typically the
only call sites consumers need.
pub fn with_static_token(self, token: Option<Arc<str>>) -> Self
pub fn with_auth_state(self, state: Option<Arc<AuthState>>) -> Self
pub fn with_actor_key_deriver( self, deriver: Option<Arc<ActorKeyDeriver>>, ) -> Self
pub fn with_resource_url(self, resource_url: Option<Arc<str>>) -> Self
Sourcepub fn with_static_token_scopes(self, scopes: Vec<String>) -> Self
pub fn with_static_token_scopes(self, scopes: Vec<String>) -> Self
Override the static-token scope list (defaults to the value pulled
from AuthConfig::static_token_scopes via Self::from_state /
Self::with_auth_state).
Sourcepub fn with_login_path(self, path: impl Into<String>) -> Self
pub fn with_login_path(self, path: impl Into<String>) -> Self
Override the browser login path used for the GET+text/html unauthenticated redirect.
Override the session cookie name read from inbound requests.