File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed
mobile/android/geckoview/src/main/java/org/mozilla/gecko Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -136,18 +136,11 @@ public static GeckoResult<WebAuthnUtils.MakeCredentialResponse> makeCredential(
136
136
final WebAuthnUtils .WebAuthnPublicCredential [] excludeList ,
137
137
final GeckoBundle authenticatorSelection ,
138
138
final byte [] clientDataHash ) {
139
- final Boolean requireResidentKey =
140
- authenticatorSelection .getBoolean ("requireResidentKey" , false );
141
139
142
- final Boolean residentKeyDiscouraged =
143
- authenticatorSelection
144
- .getString ("residentKey" , requireResidentKey ? "required" : "discouraged" )
145
- .equals ("discouraged" );
146
-
147
- // We only use Credential Manager for Passkeys. If residentKey is discouraged, use GMS FIDO2.
148
- if (residentKeyDiscouraged ) {
149
- return GeckoResult .fromException (new WebAuthnUtils .Exception ("NOT_SUPPORTED_ERR" ));
150
- }
140
+ // We use Credential Manager first. If it doesn't work, we use GMS FIDO2.
141
+ // Credential manager may support non-discoverable keys,
142
+ // Else, following the specifications, `residentKey=discouraged` allows discoverable keys too
143
+ // but prefer non-discoverable keys
151
144
if (Build .VERSION .SDK_INT < Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
152
145
return GeckoResult .fromException (new WebAuthnUtils .Exception ("NOT_SUPPORTED_ERR" ));
153
146
}
Original file line number Diff line number Diff line change @@ -362,7 +362,17 @@ public static JSONObject getJSONObjectForMakeCredential(
362
362
json .put ("excludeCredentials" , excludeCredentials );
363
363
364
364
final JSONObject authenticatorSelectionJSON = authenticatorSelection .toJSONObject ();
365
- authenticatorSelectionJSON .put ("requireResidentKey" , true );
365
+ /*
366
+ dom/webauthn/WebAuthnHandler.cpp: WebAuthnHandler::MakeCredential set `residentKey`
367
+ to "required" if there is no `residentKey` and `requireResidentKey` is true, and
368
+ `requireResidentKey` should be true if `residentKey` is "required". So we can retrieve
369
+ `requireResidentKey`'s value from `residentKey`.
370
+ `requireResidentKey` is only used if `residentKey` isn't set, so it shouldn't be used by any
371
+ authenticator that follows the specs.
372
+ */
373
+ authenticatorSelectionJSON .put (
374
+ "requireResidentKey" ,
375
+ authenticatorSelection .getString ("residentKey" , "" ).equals ("required" ));
366
376
json .put ("authenticatorSelection" , authenticatorSelectionJSON );
367
377
368
378
final JSONObject extensions = new JSONObject ();
You can’t perform that action at this time.
0 commit comments