pub trait AuthClient: Send + Sync {
// Required methods
fn validate_session<'a>(
&'a self,
token: &'a SessionToken,
) -> AuthFuture<'a, Option<User>>;
fn check_role<'a>(
&'a self,
user_id: &'a UserId,
role: &'a RoleName,
) -> AuthFuture<'a, bool>;
fn check_permission<'a>(
&'a self,
user_id: &'a UserId,
permission: &'a PermissionName,
) -> AuthFuture<'a, bool>;
fn logout<'a>(&'a self, token: &'a SessionToken) -> AuthFuture<'a, ()>;
fn login_url(&self) -> &str;
fn session_cookie_name(&self) -> &str;
}Expand description
Abstraction over embedded and external authentication modes.
Consuming projects use this trait instead of AllowThem directly, enabling
a config-flag switch between embedded mode (local SQLite) and external mode
(OIDC/JWT, Block 11) without changing handler or middleware code.
All session validation, role/permission checks, and logout flow through this trait. Login is intentionally excluded — embedded mode handles credentials directly, external mode redirects to OIDC.
Required Methods§
Sourcefn validate_session<'a>(
&'a self,
token: &'a SessionToken,
) -> AuthFuture<'a, Option<User>>
fn validate_session<'a>( &'a self, token: &'a SessionToken, ) -> AuthFuture<'a, Option<User>>
Validate a session token and return the active user.
Returns Ok(None) when the token is invalid, expired, or the user is
inactive. Returns Err only on infrastructure failures (DB, network).
Sourcefn check_role<'a>(
&'a self,
user_id: &'a UserId,
role: &'a RoleName,
) -> AuthFuture<'a, bool>
fn check_role<'a>( &'a self, user_id: &'a UserId, role: &'a RoleName, ) -> AuthFuture<'a, bool>
Check whether a user has the given role.
Sourcefn check_permission<'a>(
&'a self,
user_id: &'a UserId,
permission: &'a PermissionName,
) -> AuthFuture<'a, bool>
fn check_permission<'a>( &'a self, user_id: &'a UserId, permission: &'a PermissionName, ) -> AuthFuture<'a, bool>
Check whether a user has the given permission (direct or via role).
Sourcefn logout<'a>(&'a self, token: &'a SessionToken) -> AuthFuture<'a, ()>
fn logout<'a>(&'a self, token: &'a SessionToken) -> AuthFuture<'a, ()>
Invalidate a session. Fire-and-forget — non-existent sessions are not errors.
The cookie name used for session tokens.