Bug 1400662 - Prefer the USB token if the softtoken is enabled as well r=jcj
authorTim Taubert <ttaubert@mozilla.com>
Sun, 17 Sep 2017 20:14:54 +0200
changeset 381377 a2ed201095ea183c4657aae5d961d8c978b06a9d
parent 381376 26289fa4d71ac9a6fefde68643a17cd0517a81d9
child 381378 8a9f6ef5c3d444dd96d1d90602906a3fd62947e0
push id32526
push userarchaeopteryx@coole-files.de
push dateSun, 17 Sep 2017 21:32:35 +0000
treeherdermozilla-central@ae39864562c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcj
bugs1400662
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1400662 - Prefer the USB token if the softtoken is enabled as well r=jcj Bug #: 1400662 Differential Revision: https://phabricator.services.mozilla.com/D63
dom/webauthn/U2FTokenManager.cpp
--- a/dom/webauthn/U2FTokenManager.cpp
+++ b/dom/webauthn/U2FTokenManager.cpp
@@ -192,34 +192,33 @@ U2FTokenManager::GetTokenManagerImpl()
 {
   MOZ_ASSERT(U2FPrefManager::Get());
 
   if (mTokenManagerImpl) {
     return mTokenManagerImpl;
   }
 
   auto pm = U2FPrefManager::Get();
-  bool useSoftToken = pm->GetSoftTokenEnabled();
-  bool useUsbToken = pm->GetUsbTokenEnabled();
 
-  // At least one token type must be enabled.
-  // We currently don't support soft and USB tokens enabled at
-  // the same time as the softtoken would always win the race to register.
+  // Prefer the HW token, even if the softtoken is enabled too.
+  // We currently don't support soft and USB tokens enabled at the
+  // same time as the softtoken would always win the race to register.
   // We could support it for signing though...
-  if (!(useSoftToken ^ useUsbToken)) {
-    return nullptr;
+  if (pm->GetUsbTokenEnabled()) {
+    return new U2FHIDTokenManager();
   }
 
-  if (useSoftToken) {
+  if (pm->GetSoftTokenEnabled()) {
     return new U2FSoftTokenManager(pm->GetSoftTokenCounter());
   }
 
   // TODO Use WebAuthnRequest to aggregate results from all transports,
   //      once we have multiple HW transport types.
-  return new U2FHIDTokenManager();
+
+  return nullptr;
 }
 
 void
 U2FTokenManager::Register(PWebAuthnTransactionParent* aTransactionParent,
                           const WebAuthnTransactionInfo& aTransactionInfo)
 {
   MOZ_LOG(gU2FTokenManagerLog, LogLevel::Debug, ("U2FAuthRegister"));