pub struct AuthConfig {
pub enabled: bool,
pub username: String,
pub password_hash: String,
pub session_timeout: Duration,
pub max_failed_attempts: u32,
pub lockout_duration: Duration,
}Expand description
Authentication configuration for the web dashboard.
Controls authentication behavior including credentials, session management, and security policies like rate limiting and account lockout.
§Examples
use hammerwork_web::config::AuthConfig;
use std::time::Duration;
// Default configuration (authentication enabled)
let auth_config = AuthConfig::default();
assert!(auth_config.enabled);
assert_eq!(auth_config.username, "admin");
assert_eq!(auth_config.max_failed_attempts, 5);
// Custom configuration
let auth_config = AuthConfig {
enabled: true,
username: "dashboard_admin".to_string(),
password_hash: "$2b$12$hash...".to_string(),
session_timeout: Duration::from_secs(4 * 60 * 60), // 4 hours
max_failed_attempts: 3,
lockout_duration: Duration::from_secs(30 * 60), // 30 minutes
};
assert_eq!(auth_config.username, "dashboard_admin");
assert_eq!(auth_config.max_failed_attempts, 3);Fields§
§enabled: boolWhether authentication is enabled
username: StringUsername for basic authentication
password_hash: StringBcrypt hash of the password
session_timeout: DurationSession timeout duration
max_failed_attempts: u32Maximum number of failed login attempts
lockout_duration: DurationLockout duration after max failed attempts
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
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>
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 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>
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