pub struct AuthContext { /* private fields */ }Expand description
Central authentication context that can be shared across all mountable interfaces
Implementations§
Source§impl AuthContext
 
impl AuthContext
Sourcepub async fn new(config: AuthContextConfig) -> Result<Self>
 
pub async fn new(config: AuthContextConfig) -> Result<Self>
Create a new authentication context
Sourcepub async fn initialize_features(&mut self) -> Result<()>
 
pub async fn initialize_features(&mut self) -> Result<()>
Initialize all enabled authentication features
Sourcepub async fn authenticate_request(
    &self,
    request: &Request,
) -> AuthMiddlewareResult
 
pub async fn authenticate_request( &self, request: &Request, ) -> AuthMiddlewareResult
Authenticate a request and extract user session
Sourcepub async fn check_permissions(
    &self,
    user_session: &UserSession,
    required_permissions: &[String],
) -> bool
 
pub async fn check_permissions( &self, user_session: &UserSession, required_permissions: &[String], ) -> bool
Check if user has required permissions
Sourcepub async fn create_token(
    &self,
    user_id: &str,
    permissions: Vec<String>,
) -> Result<String>
 
pub async fn create_token( &self, user_id: &str, permissions: Vec<String>, ) -> Result<String>
Create an authentication token for a user
Sourcepub async fn create_api_key(
    &self,
    user_id: &str,
    expires_in: Option<Duration>,
) -> Result<String>
 
pub async fn create_api_key( &self, user_id: &str, expires_in: Option<Duration>, ) -> Result<String>
Create an API key for a user
Sourcepub async fn revoke_token(&self, token: &str) -> Result<()>
 
pub async fn revoke_token(&self, token: &str) -> Result<()>
Revoke a token or API key
Sourcepub async fn get_user_session(&self, user_id: &str) -> Option<UserSession>
 
pub async fn get_user_session(&self, user_id: &str) -> Option<UserSession>
Get user session by user ID
Sourcepub fn config(&self) -> &AuthContextConfig
 
pub fn config(&self) -> &AuthContextConfig
Get configuration
Sourcepub fn auth_framework(&self) -> &Arc<AuthFramework>
 
pub fn auth_framework(&self) -> &Arc<AuthFramework>
Get the underlying auth framework (for advanced usage)
Sourcepub fn is_oauth2_enabled(&self) -> bool
 
pub fn is_oauth2_enabled(&self) -> bool
Check if OAuth2 server is enabled
Sourcepub fn is_oidc_enabled(&self) -> bool
 
pub fn is_oidc_enabled(&self) -> bool
Check if OIDC provider is enabled
Sourcepub fn is_audit_logging_enabled(&self) -> bool
 
pub fn is_audit_logging_enabled(&self) -> bool
Check if audit logging is enabled
Sourcepub fn is_rate_limiting_enabled(&self) -> bool
 
pub fn is_rate_limiting_enabled(&self) -> bool
Check if rate limiting is enabled
Sourcepub fn is_mfa_enabled(&self) -> bool
 
pub fn is_mfa_enabled(&self) -> bool
Check if MFA is enabled
Sourcepub fn is_session_management_enabled(&self) -> bool
 
pub fn is_session_management_enabled(&self) -> bool
Check if session management is enabled
Sourcepub async fn enable_oauth2_server(&mut self) -> Result<()>
 
pub async fn enable_oauth2_server(&mut self) -> Result<()>
Enable OAuth2 server functionality
Sourcepub async fn enable_oidc_provider(&mut self) -> Result<()>
 
pub async fn enable_oidc_provider(&mut self) -> Result<()>
Enable OIDC provider functionality
Sourcepub async fn enable_audit_logging(&mut self) -> Result<()>
 
pub async fn enable_audit_logging(&mut self) -> Result<()>
Enable audit logging
Sourcepub async fn enable_rate_limiting(&mut self) -> Result<()>
 
pub async fn enable_rate_limiting(&mut self) -> Result<()>
Enable rate limiting
Sourcepub async fn enable_mfa(&mut self) -> Result<()>
 
pub async fn enable_mfa(&mut self) -> Result<()>
Enable multi-factor authentication
Sourcepub async fn create_user_with_password(
    &self,
    user_id: &str,
    username: &str,
    email: &str,
    _password: &str,
    permissions: Vec<String>,
    roles: Vec<String>,
) -> Result<UserSession>
 
pub async fn create_user_with_password( &self, user_id: &str, username: &str, email: &str, _password: &str, permissions: Vec<String>, roles: Vec<String>, ) -> Result<UserSession>
Create a user with password authentication
Sourcepub async fn authenticate_oauth2(
    &self,
    _provider: &str,
    _authorization_code: &str,
    _redirect_uri: &str,
) -> Result<UserSession>
 
pub async fn authenticate_oauth2( &self, _provider: &str, _authorization_code: &str, _redirect_uri: &str, ) -> Result<UserSession>
Authenticate with OAuth2 provider
Sourcepub async fn generate_totp_secret(&self, _user_id: &str) -> Result<String>
 
pub async fn generate_totp_secret(&self, _user_id: &str) -> Result<String>
Generate TOTP secret for user
Sourcepub async fn log_auth_event(
    &self,
    event_type: &str,
    user_id: &str,
    success: bool,
) -> Result<()>
 
pub async fn log_auth_event( &self, event_type: &str, user_id: &str, success: bool, ) -> Result<()>
Log authentication event for audit
Sourcepub async fn check_rate_limit(&self, _user_id: &str) -> Result<bool>
 
pub async fn check_rate_limit(&self, _user_id: &str) -> Result<bool>
Check rate limit for user
Trait Implementations§
Source§impl Clone for AuthContext
 
impl Clone for AuthContext
Source§fn clone(&self) -> AuthContext
 
fn clone(&self) -> AuthContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AuthContext
impl !RefUnwindSafe for AuthContext
impl Send for AuthContext
impl Sync for AuthContext
impl Unpin for AuthContext
impl !UnwindSafe for AuthContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more