pub struct PasswordPolicy {
pub min_length: usize,
pub max_length: usize,
pub require_uppercase: bool,
pub require_lowercase: bool,
pub require_digit: bool,
pub require_special: bool,
pub banned_passwords: HashSet<String>,
pub min_entropy: f64,
}Expand description
Enhanced password validation configuration
Fields§
§min_length: usizeMinimum password length
max_length: usizeMaximum password length
require_uppercase: boolRequire at least one uppercase letter
require_lowercase: boolRequire at least one lowercase letter
require_digit: boolRequire at least one digit
require_special: boolRequire at least one special character
banned_passwords: HashSet<String>List of banned common passwords
min_entropy: f64Minimum entropy requirement
Implementations§
Source§impl PasswordPolicy
impl PasswordPolicy
Sourcepub fn nist_800_63b() -> Self
pub fn nist_800_63b() -> Self
NIST SP 800-63B compliant policy.
Follows modern NIST guidance: no arbitrary composition rules, focus on length and entropy. Banned password list still applies.
use auth_framework::utils::validation::PasswordPolicy;
let policy = PasswordPolicy::nist_800_63b();
assert_eq!(policy.min_length, 8);
assert!(!policy.require_special);Sourcepub fn high_security() -> Self
pub fn high_security() -> Self
High-security policy with strict composition requirements.
Suitable for admin accounts and sensitive systems.
use auth_framework::utils::validation::PasswordPolicy;
let policy = PasswordPolicy::high_security();
assert_eq!(policy.min_length, 12);
assert!(policy.require_special);Sourcepub fn with_banned_words(self, words: &[&str]) -> Self
pub fn with_banned_words(self, words: &[&str]) -> Self
Add custom banned passwords on top of the existing list.
Words are lowercased before insertion.
Sourcepub fn builder() -> PasswordPolicyBuilder
pub fn builder() -> PasswordPolicyBuilder
Create a builder starting from the default policy.
Trait Implementations§
Source§impl Clone for PasswordPolicy
impl Clone for PasswordPolicy
Source§fn clone(&self) -> PasswordPolicy
fn clone(&self) -> PasswordPolicy
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 PasswordPolicy
impl Debug for PasswordPolicy
Auto Trait Implementations§
impl Freeze for PasswordPolicy
impl RefUnwindSafe for PasswordPolicy
impl Send for PasswordPolicy
impl Sync for PasswordPolicy
impl Unpin for PasswordPolicy
impl UnsafeUnpin for PasswordPolicy
impl UnwindSafe for PasswordPolicy
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
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