diff --git a/.env.template b/.env.template index 3ce84263..de6f11f9 100644 --- a/.env.template +++ b/.env.template @@ -602,10 +602,9 @@ ## Note that the checkbox would still be present, but ignored. # DISABLE_2FA_REMEMBER=false -## WebAuthn 2FA user verification policy -## Valid values are "discouraged" and "preferred". -## Setting this to "preferred" allows clients to request PIN or biometric verification when supported by the authenticator. -# WEBAUTHN_2FA_USER_VERIFICATION=discouraged +## Set WebAuthn 2FA user verification to preferred +## When enabled, compatible authenticators can request PIN or biometric verification. +# WEBAUTHN_2FA_USER_VERIFICATION=false ## ## Authenticator Settings ## Disable authenticator time drifted codes to be valid. diff --git a/src/api/core/two_factor/webauthn.rs b/src/api/core/two_factor/webauthn.rs index d0dd2b6d..98542311 100644 --- a/src/api/core/two_factor/webauthn.rs +++ b/src/api/core/two_factor/webauthn.rs @@ -45,13 +45,14 @@ static WEBAUTHN: LazyLock = LazyLock::new(|| { }); fn user_verification_policy() -> UserVerificationPolicy { - user_verification_policy_from_config(&CONFIG.webauthn_2fa_user_verification()) + user_verification_policy_from_config(CONFIG.webauthn_2fa_user_verification()) } -fn user_verification_policy_from_config(value: &str) -> UserVerificationPolicy { - match value { - "preferred" => UserVerificationPolicy::Preferred, - _ => UserVerificationPolicy::Discouraged_DO_NOT_USE, +fn user_verification_policy_from_config(preferred: bool) -> UserVerificationPolicy { + if preferred { + UserVerificationPolicy::Preferred + } else { + UserVerificationPolicy::Discouraged_DO_NOT_USE } } @@ -537,11 +538,11 @@ mod tests { #[test] fn configured_user_verification_policy() { assert_eq!( - serde_json::to_value(user_verification_policy_from_config("discouraged")).unwrap(), + serde_json::to_value(user_verification_policy_from_config(false)).unwrap(), "discouraged" ); assert_eq!( - serde_json::to_value(user_verification_policy_from_config("preferred")).unwrap(), + serde_json::to_value(user_verification_policy_from_config(true)).unwrap(), "preferred" ); } diff --git a/src/config.rs b/src/config.rs index 29f717a0..f49fbb98 100644 --- a/src/config.rs +++ b/src/config.rs @@ -712,8 +712,8 @@ make_config! { /// Note that the checkbox would still be present, but ignored. disable_2fa_remember: bool, true, def, false; - /// WebAuthn 2FA user verification |> Controls whether PIN or biometric user verification is discouraged or preferred for WebAuthn 2FA. - webauthn_2fa_user_verification: String, true, def, "discouraged".to_owned(); + /// Set WebAuthn 2FA user verification to preferred |> Discouraged avoids requesting a PIN or biometric check for standard WebAuthn 2FA. Preferred asks compatible authenticators for user verification and can improve compatibility with some security keys. + webauthn_2fa_user_verification: bool, true, def, false; /// Disable authenticator time drifted codes to be valid |> Enabling this only allows the current TOTP code to be valid /// TOTP codes of the previous and next 30 seconds will be invalid. @@ -985,13 +985,6 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> { err!("`DATABASE_MIN_CONNS` must be smaller than or equal to `DATABASE_MAX_CONNS`."); } - match cfg.webauthn_2fa_user_verification.as_str() { - "discouraged" | "preferred" => (), - _ => err!( - "`WEBAUTHN_2FA_USER_VERIFICATION` is invalid. It needs to be one of the following options: discouraged or preferred" - ), - } - if let Some(log_file) = &cfg.log_file && std::fs::OpenOptions::new().append(true).create(true).open(log_file).is_err() { diff --git a/src/static/templates/admin/settings.hbs b/src/static/templates/admin/settings.hbs index 365b5a57..cd5e3ca2 100644 --- a/src/static/templates/admin/settings.hbs +++ b/src/static/templates/admin/settings.hbs @@ -26,16 +26,6 @@ {{#case type "text" "number" "password"}}
- {{#if (eq name "webauthn_2fa_user_verification")}} - -
- Discouraged avoids requesting a PIN or biometric check for standard WebAuthn 2FA. - Preferred asks compatible authenticators for user verification and can improve compatibility with some security keys. -
- {{else}}
@@ -43,7 +33,6 @@ {{/case}}
- {{/if}}
{{/case}} {{#case type "checkbox"}}