Browse Source

use existing function to check webauthn support

0x484558 2 weeks ago
parent
commit
3c87f9cb28
Failed to extract signature
  1. 2
      src/api/core/two_factor/mod.rs
  2. 4
      src/api/core/two_factor/webauthn.rs
  3. 2
      src/api/identity.rs

2
src/api/core/two_factor/mod.rs

@ -56,7 +56,7 @@ pub fn is_twofactor_provider_usable(provider_type: i32, provider_data: Option<&s
x if x == TwoFactorType::YubiKey as i32 => {
CONFIG._enable_yubico() && CONFIG.yubico_client_id().is_some() && CONFIG.yubico_secret_key().is_some()
}
x if x == TwoFactorType::Webauthn as i32 => CONFIG.domain_set(),
x if x == TwoFactorType::Webauthn as i32 => CONFIG.is_webauthn_2fa_supported(),
x if x == TwoFactorType::Remember as i32 => !CONFIG.disable_2fa_remember(),
x if x == TwoFactorType::RecoveryCode as i32 => true,
_ => false,

4
src/api/core/two_factor/webauthn.rs

@ -108,8 +108,8 @@ impl WebauthnRegistration {
#[post("/two-factor/get-webauthn", data = "<data>")]
async fn get_webauthn(data: Json<PasswordOrOtpData>, headers: Headers, conn: DbConn) -> JsonResult {
if !CONFIG.domain_set() {
err!("`DOMAIN` environment variable is not set. Webauthn disabled")
if !CONFIG.is_webauthn_2fa_supported() {
err!("Configured `DOMAIN` is not compatible with Webauthn")
}
let data: PasswordOrOtpData = data.into_inner();

2
src/api/identity.rs

@ -887,7 +887,7 @@ async fn _json_err_twofactor(
match TwoFactorType::from_i32(*provider) {
Some(TwoFactorType::Authenticator) => { /* Nothing to do for TOTP */ }
Some(TwoFactorType::Webauthn) if CONFIG.domain_set() => {
Some(TwoFactorType::Webauthn) if CONFIG.is_webauthn_2fa_supported() => {
let request = webauthn::generate_webauthn_login(user_id, conn).await?;
result["TwoFactorProviders2"][provider.to_string()] = request.0;
}

Loading…
Cancel
Save