From 389f2e379e506235bf1718f10b6f27b1c85fb854 Mon Sep 17 00:00:00 2001 From: John Schanck Date: Tue, 12 Sep 2023 18:05:00 +0000 Subject: [PATCH] Bug 1759626 - WebAuthn isUVPAA result depends on Android resident key pref. r=keeler Differential Revision: https://phabricator.services.mozilla.com/D187926 --- dom/webauthn/PublicKeyCredential.cpp | 34 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/dom/webauthn/PublicKeyCredential.cpp b/dom/webauthn/PublicKeyCredential.cpp index 023238d4d4ee..bfeafff0e193 100644 --- a/dom/webauthn/PublicKeyCredential.cpp +++ b/dom/webauthn/PublicKeyCredential.cpp @@ -10,7 +10,7 @@ #include "nsCycleCollectionParticipant.h" #include "mozilla/dom/AuthenticatorResponse.h" #include "mozilla/HoldDropJSObjects.h" -#include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs_security.h" #ifdef XP_WIN # include "WinWebAuthnManager.h" @@ -107,17 +107,23 @@ PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable( promise->MaybeResolve(false); #elif defined(MOZ_WIDGET_ANDROID) - auto result = java::WebAuthnTokenManager:: - WebAuthnIsUserVerifyingPlatformAuthenticatorAvailable(); - auto geckoResult = java::GeckoResult::LocalRef(std::move(result)); - MozPromise::FromGeckoResult(geckoResult) - ->Then(GetMainThreadSerialEventTarget(), __func__, - [promise](const MozPromise::ResolveOrRejectValue& aValue) { - if (aValue.IsResolve()) { - promise->MaybeResolve(aValue.ResolveValue()); - } - }); + if (StaticPrefs:: + security_webauthn_webauthn_enable_android_fido2_residentkey()) { + auto result = java::WebAuthnTokenManager:: + WebAuthnIsUserVerifyingPlatformAuthenticatorAvailable(); + auto geckoResult = java::GeckoResult::LocalRef(std::move(result)); + MozPromise::FromGeckoResult(geckoResult) + ->Then( + GetMainThreadSerialEventTarget(), __func__, + [promise](const MozPromise::ResolveOrRejectValue& + aValue) { + if (aValue.IsResolve()) { + promise->MaybeResolve(aValue.ResolveValue()); + } + }); + } else { + promise->MaybeResolve(false); + } #else promise->MaybeResolve(false); #endif @@ -138,12 +144,12 @@ PublicKeyCredential::IsExternalCTAP2SecurityKeySupported(GlobalObject& aGlobal, if (WinWebAuthnManager::AreWebAuthNApisAvailable()) { promise->MaybeResolve(true); } else { - promise->MaybeResolve(Preferences::GetBool("security.webauthn.ctap2")); + promise->MaybeResolve(StaticPrefs::security_webauthn_ctap2()); } #elif defined(MOZ_WIDGET_ANDROID) promise->MaybeResolve(false); #else - promise->MaybeResolve(Preferences::GetBool("security.webauthn.ctap2")); + promise->MaybeResolve(StaticPrefs::security_webauthn_ctap2()); #endif return promise.forget();