pub struct AuthConfig {
pub token_lifetime: Duration,
pub refresh_token_lifetime: Duration,
pub enable_multi_factor: bool,
pub issuer: String,
pub audience: String,
pub secret: Option<String>,
pub storage: StorageConfig,
pub rate_limiting: RateLimitConfig,
pub security: SecurityConfig,
pub audit: AuditConfig,
pub method_configs: HashMap<String, Value>,
}Expand description
Main configuration for the authentication framework.
Fields§
§token_lifetime: DurationDefault token lifetime
refresh_token_lifetime: DurationRefresh token lifetime
enable_multi_factor: boolWhether multi-factor authentication is enabled
issuer: StringJWT issuer for token validation
audience: StringJWT audience for token validation
secret: Option<String>JWT secret key (optional - can be set via environment)
storage: StorageConfigStorage configuration
rate_limiting: RateLimitConfigRate limiting configuration
security: SecurityConfigSecurity configuration
audit: AuditConfigAudit logging configuration
method_configs: HashMap<String, Value>Custom settings for different auth methods
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn token_lifetime(self, lifetime: Duration) -> Self
pub fn token_lifetime(self, lifetime: Duration) -> Self
Set the token lifetime.
Sourcepub fn refresh_token_lifetime(self, lifetime: Duration) -> Self
pub fn refresh_token_lifetime(self, lifetime: Duration) -> Self
Set the refresh token lifetime.
Sourcepub fn enable_multi_factor(self, enabled: bool) -> Self
pub fn enable_multi_factor(self, enabled: bool) -> Self
Enable or disable multi-factor authentication.
Sourcepub fn require_mfa(self, required: bool) -> Self
pub fn require_mfa(self, required: bool) -> Self
Require MFA for all users.
Sourcepub fn enable_caching(self, _enabled: bool) -> Self
pub fn enable_caching(self, _enabled: bool) -> Self
Enable caching.
Sourcepub fn max_failed_attempts(self, _max: u32) -> Self
pub fn max_failed_attempts(self, _max: u32) -> Self
Set maximum failed attempts.
Sourcepub fn enable_rbac(self, _enabled: bool) -> Self
pub fn enable_rbac(self, _enabled: bool) -> Self
Enable RBAC.
Sourcepub fn enable_security_audit(self, _enabled: bool) -> Self
pub fn enable_security_audit(self, _enabled: bool) -> Self
Enable security audit.
Sourcepub fn enable_middleware(self, _enabled: bool) -> Self
pub fn enable_middleware(self, _enabled: bool) -> Self
Enable middleware.
Sourcepub fn storage(self, storage: StorageConfig) -> Self
pub fn storage(self, storage: StorageConfig) -> Self
Set the storage configuration.
Sourcepub fn rate_limiting(self, config: RateLimitConfig) -> Self
pub fn rate_limiting(self, config: RateLimitConfig) -> Self
Set rate limiting configuration.
Sourcepub fn security(self, config: SecurityConfig) -> Self
pub fn security(self, config: SecurityConfig) -> Self
Set security configuration.
Sourcepub fn audit(self, config: AuditConfig) -> Self
pub fn audit(self, config: AuditConfig) -> Self
Set audit configuration.
Sourcepub fn method_config(
self,
method_name: impl Into<String>,
config: impl Serialize,
) -> Result<Self>
pub fn method_config( self, method_name: impl Into<String>, config: impl Serialize, ) -> Result<Self>
Add configuration for a specific auth method.
Sourcepub fn get_method_config<T>(&self, method_name: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
pub fn get_method_config<T>(&self, method_name: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
Get configuration for a specific auth method.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthConfig
impl Debug for AuthConfig
Source§impl Default for AuthConfig
impl Default for AuthConfig
Source§impl<'de> Deserialize<'de> for AuthConfig
impl<'de> Deserialize<'de> for AuthConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnsafeUnpin for AuthConfig
impl UnwindSafe for AuthConfig
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