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);Debug never shows password_hash.
Fields§
§enabled: boolWhether authentication is enabled
username: StringUsername for basic authentication
password_hash: StringBcrypt hash of the password. It is only ever verified with bcrypt (the auth
feature), never compared to the password as text.
session_timeout: DurationUpper bound on how long a successful credential check is remembered (at most
crate::auth::VERIFIED_CREDENTIALS_TTL); zero re-verifies every request.
max_failed_attempts: u32Failed attempts from one client address before it is locked out
lockout_duration: DurationHow long a locked-out client is refused. A failure older than this no longer counts.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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