Skip to content

Commit

Permalink
Disable LDAP commands in groups
Browse files Browse the repository at this point in the history
  • Loading branch information
cofob committed Aug 11, 2024
1 parent 3c4e235 commit f6e596d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/modules/ldap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ const PASSWORD_GENERATOR: PasswordGenerator = PasswordGenerator {
#[command(rename_rule = "snake_case")]
pub enum Commands {
#[command(description = "Register in LDAP.")]
#[custom(in_private = true, resident = true)]
#[custom(in_group = false, resident = true)]
LdapRegister(String),
#[command(description = "Reset LDAP password.")]
#[custom(in_private = true, resident = true)]
#[custom(in_group = false, resident = true)]
LdapResetPassword,
#[command(description = "Update LDAP settings.")]
#[custom(in_private = true, resident = true)]
#[custom(in_group = false, resident = true)]
LdapUpdate(String),
#[command(description = "Show your LDAP groups.")]
#[custom(in_private = true, resident = true)]
LdapGroups,
// #[command(description = "Show your LDAP groups.")]
// #[custom(in_group = false, resident = true)]
// LdapGroups,
}

/// Control personal configuration.
Expand Down Expand Up @@ -87,7 +87,7 @@ async fn start<'a>(
ldap_reset_password(bot, env, msg).await?;
}
Commands::LdapUpdate(args) => ldap_update(bot, env, msg, &args).await?,
Commands::LdapGroups => ldap_groups(bot, env, msg).await?,
// Commands::LdapGroups => ldap_groups(bot, env, msg).await?,
}
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/ldap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ impl Default for Sha512PasswordHash {
impl PasswordHash for Sha512PasswordHash {
fn hash_password(&self, password: &str) -> String {
use sha_crypt::{sha512_simple, Sha512Params};
let params = Sha512Params::new(10_000).expect("failed to create sha512 hashing params");
let params = Sha512Params::new(10_000)
.expect("failed to create sha512 hashing params");
let hashed_password =
sha512_simple(password, &params).expect("failed to hash password");
format!("{{CRYPT}}{hashed_password}")
Expand Down

0 comments on commit f6e596d

Please sign in to comment.