Skip to content

Commit

Permalink
chore: used parse_display as well for PasswordHash
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Aug 21, 2024
1 parent 9980757 commit 2cb3d5b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/openldap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,15 @@ impl OpenLDAP {
/// Set hash to be used in generation of user passwords.
/// Default: [`PasswordHash::SSHA`].
pub fn with_ldap_password_hash(mut self, password_hash: PasswordHash) -> Self {
self.env_vars.insert(
"LDAP_PASSWORD_HASH".to_owned(),
match password_hash {
PasswordHash::SSHA => "{SSHA}".to_owned(),
PasswordHash::SHA => "{SHA}".to_owned(),
PasswordHash::SMD5 => "{SMD5}".to_owned(),
PasswordHash::MD5 => "{MD5}".to_owned(),
PasswordHash::CRYPT => "{CRYPT}".to_owned(),
PasswordHash::CLEARTEXT => "{CLEARTEXT}".to_owned(),
},
);
self.env_vars
.insert("LDAP_PASSWORD_HASH".to_owned(), password_hash.to_string());
self
}
}

/// hash to be used in generation of user passwords.
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Display, FromStr, Default, Debug, Clone, Copy, Eq, PartialEq)]
#[display("{{{}}}")] // it's escaped curly braces => `SSHA` gets displayed as `{SSHA}`
pub enum PasswordHash {
#[default]
/// [`PasswordHash::SHA`], but with a salt.
Expand Down

0 comments on commit 2cb3d5b

Please sign in to comment.