Skip to main content

SecurePassword

Trait SecurePassword 

Source
pub trait SecurePassword {
Show 13 methods // Required methods fn password_digest(&self) -> Option<&str>; fn set_password_digest(&mut self, digest: String); // Provided methods fn set_password( &mut self, password: &str, ) -> Result<(), SecurePasswordError> { ... } fn set_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<(), SecurePasswordError> { ... } fn update_password( &mut self, password: &str, ) -> Result<bool, SecurePasswordError> { ... } fn update_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<bool, SecurePasswordError> { ... } fn set_password_with_algorithm( &mut self, password: &str, algorithm: &str, ) -> Result<(), SecurePasswordError> { ... } fn authenticate(&self, password: &str) -> Result<bool, SecurePasswordError> { ... } fn authenticate_password(&self, challenge: Option<&str>) -> bool { ... } fn generate_recovery_token(&self) -> Result<String, SecurePasswordError> { ... } fn verify_recovery_token(&self, token: &str) -> bool { ... } fn has_password(&self) -> bool { ... } fn password_salt(&self) -> Option<String> { ... }
}
Expand description

Trait for models that store a password digest.

Required Methods§

Source

fn password_digest(&self) -> Option<&str>

Returns the stored password digest, if one exists.

Source

fn set_password_digest(&mut self, digest: String)

Replaces the stored password digest.

Provided Methods§

Source

fn set_password(&mut self, password: &str) -> Result<(), SecurePasswordError>

Hashes and stores a password using the default algorithm registry entry.

Source

fn set_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<(), SecurePasswordError>

Hashes and stores a password when the optional confirmation matches.

Source

fn update_password( &mut self, password: &str, ) -> Result<bool, SecurePasswordError>

Updates an existing digest, treating a blank password as “no change”.

Source

fn update_password_confirmed( &mut self, password: &str, confirmation: Option<&str>, ) -> Result<bool, SecurePasswordError>

Updates an existing digest with optional confirmation, treating a blank password as “no change”.

Source

fn set_password_with_algorithm( &mut self, password: &str, algorithm: &str, ) -> Result<(), SecurePasswordError>

Hashes and stores a password using a registered algorithm.

Source

fn authenticate(&self, password: &str) -> Result<bool, SecurePasswordError>

Verifies a password against the stored digest.

Source

fn authenticate_password(&self, challenge: Option<&str>) -> bool

Verifies an optional challenge and returns false for missing, blank, or malformed inputs.

Source

fn generate_recovery_token(&self) -> Result<String, SecurePasswordError>

Generates a self-contained recovery token bound to the current password digest.

Source

fn verify_recovery_token(&self, token: &str) -> bool

Verifies a recovery token against the current password digest.

Source

fn has_password(&self) -> bool

Returns true when a password digest is present.

Source

fn password_salt(&self) -> Option<String>

Extracts the salt encoded in the current password digest.

Implementors§