mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-10 20:01:27 -06:00
use existing function to check webauthn support
This commit is contained in:
parent
737016863a
commit
1bb32daaf9
@ -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,
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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…
Reference in New Issue
Block a user