AuthContext

Struct AuthContext 

Source
pub struct AuthContext { /* private fields */ }
Expand description

Central authentication context that can be shared across all mountable interfaces

Implementations§

Source§

impl AuthContext

Source

pub async fn new(config: AuthContextConfig) -> Result<Self>

Create a new authentication context

Source

pub async fn initialize_features(&mut self) -> Result<()>

Initialize all enabled authentication features

Source

pub async fn authenticate_request( &self, request: &Request, ) -> AuthMiddlewareResult

Authenticate a request and extract user session

Source

pub async fn check_permissions( &self, user_session: &UserSession, required_permissions: &[String], ) -> bool

Check if user has required permissions

Source

pub async fn create_token( &self, user_id: &str, permissions: Vec<String>, ) -> Result<String>

Create an authentication token for a user

Source

pub async fn create_api_key( &self, user_id: &str, expires_in: Option<Duration>, ) -> Result<String>

Create an API key for a user

Source

pub async fn revoke_token(&self, token: &str) -> Result<()>

Revoke a token or API key

Source

pub async fn get_user_session(&self, user_id: &str) -> Option<UserSession>

Get user session by user ID

Source

pub fn config(&self) -> &AuthContextConfig

Get configuration

Source

pub fn auth_framework(&self) -> &Arc<AuthFramework>

Get the underlying auth framework (for advanced usage)

Source

pub fn is_oauth2_enabled(&self) -> bool

Check if OAuth2 server is enabled

Source

pub fn is_oidc_enabled(&self) -> bool

Check if OIDC provider is enabled

Source

pub fn is_audit_logging_enabled(&self) -> bool

Check if audit logging is enabled

Source

pub fn is_rate_limiting_enabled(&self) -> bool

Check if rate limiting is enabled

Source

pub fn is_mfa_enabled(&self) -> bool

Check if MFA is enabled

Source

pub fn is_session_management_enabled(&self) -> bool

Check if session management is enabled

Source

pub async fn enable_oauth2_server(&mut self) -> Result<()>

Enable OAuth2 server functionality

Source

pub async fn enable_oidc_provider(&mut self) -> Result<()>

Enable OIDC provider functionality

Source

pub async fn enable_audit_logging(&mut self) -> Result<()>

Enable audit logging

Source

pub async fn enable_rate_limiting(&mut self) -> Result<()>

Enable rate limiting

Source

pub async fn enable_mfa(&mut self) -> Result<()>

Enable multi-factor authentication

Source

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

Source

pub async fn authenticate_oauth2( &self, _provider: &str, _authorization_code: &str, _redirect_uri: &str, ) -> Result<UserSession>

Authenticate with OAuth2 provider

Source

pub async fn generate_totp_secret(&self, _user_id: &str) -> Result<String>

Generate TOTP secret for user

Source

pub async fn verify_totp(&self, _user_id: &str, _code: &str) -> Result<bool>

Verify TOTP code

Source

pub async fn log_auth_event( &self, event_type: &str, user_id: &str, success: bool, ) -> Result<()>

Log authentication event for audit

Source

pub async fn check_rate_limit(&self, _user_id: &str) -> Result<bool>

Check rate limit for user

Trait Implementations§

Source§

impl Clone for AuthContext

Source§

fn clone(&self) -> AuthContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,