pub struct AuthConfig {
pub token_lifetime: Duration,
pub refresh_token_lifetime: Duration,
pub enable_multi_factor: bool,
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
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 redis_storage(self, url: impl Into<String>) -> Self
pub fn redis_storage(self, url: impl Into<String>) -> Self
Configure Redis storage.
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnwindSafe for AuthConfig
Blanket Implementations§
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
Mutably borrows from an owned value. Read more