Skip to content

Commit d94246c

Browse files
p1gp1gmakotokato
authored andcommitted
Bug 1964526 - Get FIDO2 credProp extension from request r=geckoview-reviewers,m_kato,jschanck
Differential Revision: https://phabricator.services.mozilla.com/D253459
1 parent 97b34ff commit d94246c

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

dom/webauthn/AndroidWebAuthnService.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ AndroidWebAuthnService::MakeCredential(uint64_t aTransactionId,
192192
GECKOBUNDLE_FINISH(authSelBundle);
193193

194194
GECKOBUNDLE_START(extensionsBundle);
195+
GECKOBUNDLE_PUT(extensionsBundle, "credProps",
196+
requestedCredProps ? java::sdk::Boolean::TRUE()
197+
: java::sdk::Boolean::FALSE());
195198
GECKOBUNDLE_FINISH(extensionsBundle);
196199

197200
auto result = java::WebAuthnTokenManager::WebAuthnMakeCredential(

mobile/android/geckoview/src/main/java/org/mozilla/gecko/WebAuthnCredentialManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ private static Bundle getRequestBundleForMakeCredential(
7777
final int[] algs,
7878
final WebAuthnUtils.WebAuthnPublicCredential[] excludeList,
7979
final GeckoBundle authenticatorSelection,
80+
final GeckoBundle extensions,
8081
final byte[] clientDataHash) {
8182
try {
8283
final JSONObject requestJSON =
8384
WebAuthnUtils.getJSONObjectForMakeCredential(
84-
credentialBundle, userId, challenge, algs, excludeList, authenticatorSelection);
85+
credentialBundle,
86+
userId,
87+
challenge,
88+
algs,
89+
excludeList,
90+
authenticatorSelection,
91+
extensions);
8592
final Bundle bundle = getRequestBundle(requestJSON.toString(), clientDataHash);
8693
if (bundle == null) {
8794
return null;
@@ -135,6 +142,7 @@ public static GeckoResult<WebAuthnUtils.MakeCredentialResponse> makeCredential(
135142
final int[] algs,
136143
final WebAuthnUtils.WebAuthnPublicCredential[] excludeList,
137144
final GeckoBundle authenticatorSelection,
145+
final GeckoBundle extensions,
138146
final byte[] clientDataHash) {
139147

140148
// We use Credential Manager first. If it doesn't work, we use GMS FIDO2.
@@ -160,6 +168,7 @@ public static GeckoResult<WebAuthnUtils.MakeCredentialResponse> makeCredential(
160168
algs,
161169
excludeList,
162170
authenticatorSelection,
171+
extensions,
163172
clientDataHash);
164173
if (requestBundle == null) {
165174
return GeckoResult.fromException(new WebAuthnUtils.Exception("UNKNOWN_ERR"));

mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/WebAuthnUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ public static JSONObject getJSONObjectForMakeCredential(
331331
final byte[] challenge,
332332
final int[] algs,
333333
final WebAuthnPublicCredential[] excludeList,
334-
final GeckoBundle authenticatorSelection)
334+
final GeckoBundle authenticatorSelection,
335+
final GeckoBundle extensions)
335336
throws JSONException {
336337
final JSONObject json = credentialBundle.toJSONObject();
337338
// origin is unnecessary for requestJSON.
@@ -375,9 +376,8 @@ public static JSONObject getJSONObjectForMakeCredential(
375376
authenticatorSelection.getString("residentKey", "").equals("required"));
376377
json.put("authenticatorSelection", authenticatorSelectionJSON);
377378

378-
final JSONObject extensions = new JSONObject();
379-
extensions.put("credProps", true);
380-
json.put("extensions", extensions);
379+
final JSONObject extensionsJSON = extensions.toJSONObject();
380+
json.put("extensions", extensionsJSON);
381381

382382
if (DEBUG) {
383383
Log.d(LOGTAG, "getJSONObjectForMakeCredential: JSON=\"" + json.toString() + "\"");

mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebAuthnTokenManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ private static GeckoResult<WebAuthnUtils.MakeCredentialResponse> webAuthnMakeCre
337337
algs,
338338
excludeList,
339339
authenticatorSelection,
340+
extensions,
340341
clientDataHashBytes)
341342
.accept(
342343
response -> result.complete(response),

mobile/android/geckoview/src/test/java/org/mozilla/gecko/util/WebAuthnUtilsTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public void requestJSONForMakeCredentail() throws Exception {
4141
authenticatorSelection.putString("authenticatorAttachment", "platform");
4242
authenticatorSelection.putString("residentKey", "required");
4343

44+
final GeckoBundle extensions = new GeckoBundle(1);
45+
extensions.putBoolean("credProps", true);
46+
4447
final byte[] userId = new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7};
4548
final byte[] challenge =
4649
new byte[] {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
@@ -50,7 +53,13 @@ public void requestJSONForMakeCredentail() throws Exception {
5053

5154
final JSONObject request =
5255
WebAuthnUtils.getJSONObjectForMakeCredential(
53-
credentialBundle, userId, challenge, algs, excludeList, authenticatorSelection);
56+
credentialBundle,
57+
userId,
58+
challenge,
59+
algs,
60+
excludeList,
61+
authenticatorSelection,
62+
extensions);
5463

5564
final JSONObject expected =
5665
new JSONObject(

0 commit comments

Comments
 (0)