JMAP Registry API implementation - part 8
This commit is contained in:
@@ -42,13 +42,13 @@ impl LdapDirectory {
|
||||
base_dn: config.base_dn,
|
||||
filter_login: LdapFilter::new(&config.filter_login)?,
|
||||
filter_mailbox: LdapFilter::new(&config.filter_mailbox)?,
|
||||
attr_class: config.attr_class,
|
||||
attr_groups: config.attr_groups,
|
||||
attr_description: config.attr_description,
|
||||
attr_secret: config.attr_secret,
|
||||
attr_secret_changed: config.attr_secret_changed,
|
||||
attr_email: config.attr_email,
|
||||
attr_email_alias: config.attr_email_alias,
|
||||
attr_class: config.attr_class.into_inner(),
|
||||
attr_groups: config.attr_groups.into_inner(),
|
||||
attr_description: config.attr_description.into_inner(),
|
||||
attr_secret: config.attr_secret.into_inner(),
|
||||
attr_secret_changed: config.attr_secret_changed.into_inner(),
|
||||
attr_email: config.attr_email.into_inner(),
|
||||
attr_email_alias: config.attr_email_alias.into_inner(),
|
||||
group_class: config.group_class,
|
||||
attrs_principal: vec![],
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ impl OpenIdDirectory {
|
||||
claim_email: config.claim_email,
|
||||
claim_name: config.claim_name,
|
||||
require_aud: config.require_audience,
|
||||
require_scopes: config.require_scopes,
|
||||
require_scopes: config.require_scopes.into_inner(),
|
||||
}
|
||||
}
|
||||
structs::OidcDirectory::Jwt(config) => OpenIdDirectory::Jwt {
|
||||
|
||||
@@ -61,6 +61,29 @@ pub async fn verify_mfa_secret_hash(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verify_otp_auth(otp_auth: Option<&str>, otp_code: Option<&str>) -> trc::Result<bool> {
|
||||
if let Some(otp_auth) = otp_auth {
|
||||
if let Some(otp_code) = otp_code {
|
||||
TOTP::from_url(otp_auth)
|
||||
.map_err(|err| {
|
||||
trc::AuthEvent::Error
|
||||
.reason(err)
|
||||
.details(otp_auth.to_string())
|
||||
})?
|
||||
.check_current(otp_code)
|
||||
.map_err(|err| {
|
||||
trc::AuthEvent::Error
|
||||
.reason(err)
|
||||
.details("TOTP verification failed")
|
||||
})
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
} else {
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
async fn verify_hash_prefix(hashed_secret: &str, secret: &[u8]) -> trc::Result<bool> {
|
||||
if hashed_secret.starts_with("$argon2")
|
||||
|| hashed_secret.starts_with("$pbkdf2")
|
||||
|
||||
Reference in New Issue
Block a user