Title: [290515] trunk
Revision
290515
Author
[email protected]
Date
2022-02-25 10:44:20 -0800 (Fri, 25 Feb 2022)

Log Message

[WebAuthn] Use default pubKeyCredParams if empty in makeCredential
https://bugs.webkit.org/show_bug.cgi?id=237109
rdar://problem/89376484

Reviewed by Brent Fulgham.

Source/WebCore:

The Web Authentication level 2 spec was updated to clarify that
a set of default pubKeyCredParams should be used if the list
supplied by the RP is empty. This patch starts using
the default and updates associated tests.

* Modules/webauthn/AuthenticatorCoordinator.cpp:
(WebCore::AuthenticatorCoordinator::create const):
* Modules/webauthn/PublicKeyCredentialCreationOptions.h:
* Modules/webauthn/WebAuthenticationConstants.h:

LayoutTests:

Update tests to take in account using default pubKeyCredParams.

* http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt:
* http/wpt/webauthn/public-key-credential-create-failure.https.html:
* http/wpt/webauthn/public-key-credential-create-success-hid.https-expected.txt:
* http/wpt/webauthn/public-key-credential-create-success-hid.https.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290514 => 290515)


--- trunk/LayoutTests/ChangeLog	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/LayoutTests/ChangeLog	2022-02-25 18:44:20 UTC (rev 290515)
@@ -1,3 +1,18 @@
+2022-02-25  J Pascoe  <[email protected]>
+
+        [WebAuthn] Use default pubKeyCredParams if empty in makeCredential
+        https://bugs.webkit.org/show_bug.cgi?id=237109
+        rdar://problem/89376484
+
+        Reviewed by Brent Fulgham.
+
+        Update tests to take in account using default pubKeyCredParams.
+
+        * http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt:
+        * http/wpt/webauthn/public-key-credential-create-failure.https.html:
+        * http/wpt/webauthn/public-key-credential-create-success-hid.https-expected.txt:
+        * http/wpt/webauthn/public-key-credential-create-success-hid.https.html:
+
 2022-02-25  Alan Bujtas  <[email protected]>
 
         [Tables] Incorrect table sizing when colgroup comes after tbody

Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt (290514 => 290515)


--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt	2022-02-25 18:44:20 UTC (rev 290515)
@@ -7,7 +7,6 @@
 
 PASS PublicKeyCredential's [[create]] with timeout
 PASS PublicKeyCredential's [[create]] with a mismatched RP ID
-PASS PublicKeyCredential's [[create]] with an empty pubKeyCredParams
 PASS PublicKeyCredential's [[create]] with two consecutive requests
 PASS PublicKeyCredential's [[create]] with two consecutive requests (2)
 PASS PublicKeyCredential's [[create]] with new requests in a new page

Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html (290514 => 290515)


--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html	2022-02-25 18:44:20 UTC (rev 290515)
@@ -54,27 +54,6 @@
         const options = {
             publicKey: {
                 rp: {
-                    name: "localhost",
-                    id: "localhost"
-                },
-                user: {
-                    name: "John Appleseed",
-                    id: asciiToUint8Array("123456"),
-                    displayName: "Appleseed",
-                },
-                challenge: asciiToUint8Array("123456"),
-                pubKeyCredParams: [ ],
-            }
-        };
-
-        return promiseRejects(t, "NotSupportedError",
-            navigator.credentials.create(options), "Unable to create credential because options.pubKeyCredParams is empty.");
-    }, "PublicKeyCredential's [[create]] with an empty pubKeyCredParams");
-
-    promise_test(function(t) {
-        const options = {
-            publicKey: {
-                rp: {
                     name: "example.com"
                 },
                 user: {

Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https-expected.txt (290514 => 290515)


--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https-expected.txt	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https-expected.txt	2022-02-25 18:44:20 UTC (rev 290515)
@@ -10,8 +10,10 @@
 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' or 'navigator.credentials.get' within user activated events.
 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' or 'navigator.credentials.get' within user activated events.
 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' or 'navigator.credentials.get' within user activated events.
+CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' or 'navigator.credentials.get' within user activated events.
 
 PASS PublicKeyCredential's [[create]] with minimum options in a mock hid authenticator.
+PASS PublicKeyCredential's [[create]] with empty pubKeyCredParams in a mock hid authenticator.
 PASS PublicKeyCredential's [[create]] with authenticatorSelection { 'cross-platform' } in a mock hid authenticator.
 PASS PublicKeyCredential's [[create]] with requireResidentKey { false } in a mock hid authenticator.
 PASS PublicKeyCredential's [[create]] with userVerification { 'preferred' } in a mock hid authenticator.

Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html (290514 => 290515)


--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html	2022-02-25 18:44:20 UTC (rev 290515)
@@ -43,6 +43,28 @@
                     displayName: "Appleseed",
                 },
                 challenge: Base64URL.parse("MTIzNDU2"),
+                pubKeyCredParams: [],
+                timeout: 100
+            }
+        };
+
+        return navigator.credentials.create(options).then(credential => {
+            checkCtapMakeCredentialResult(credential);
+        });
+    }, "PublicKeyCredential's [[create]] with empty pubKeyCredParams in a mock hid authenticator.");
+
+    promise_test(t => {
+        const options = {
+            publicKey: {
+                rp: {
+                    name: "localhost",
+                },
+                user: {
+                    name: "John Appleseed",
+                    id: Base64URL.parse(testUserhandleBase64),
+                    displayName: "Appleseed",
+                },
+                challenge: Base64URL.parse("MTIzNDU2"),
                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
                 authenticatorSelection: { authenticatorAttachment: "cross-platform" },
                 timeout: 100

Modified: trunk/Source/WebCore/ChangeLog (290514 => 290515)


--- trunk/Source/WebCore/ChangeLog	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/Source/WebCore/ChangeLog	2022-02-25 18:44:20 UTC (rev 290515)
@@ -1,3 +1,20 @@
+2022-02-25  J Pascoe  <[email protected]>
+        [WebAuthn] Use default pubKeyCredParams if empty in makeCredential
+        https://bugs.webkit.org/show_bug.cgi?id=237109
+        rdar://problem/89376484
+
+        Reviewed by Brent Fulgham.
+
+        The Web Authentication level 2 spec was updated to clarify that
+        a set of default pubKeyCredParams should be used if the list
+        supplied by the RP is empty. This patch starts using
+        the default and updates associated tests.
+
+        * Modules/webauthn/AuthenticatorCoordinator.cpp:
+        (WebCore::AuthenticatorCoordinator::create const):
+        * Modules/webauthn/PublicKeyCredentialCreationOptions.h:
+        * Modules/webauthn/WebAuthenticationConstants.h:
+
 2022-02-25  Chris Dumez  <[email protected]>
 
         Use modern Hasher in ContentExtensionsActions

Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp (290514 => 290515)


--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp	2022-02-25 18:44:20 UTC (rev 290515)
@@ -138,11 +138,18 @@
         options.rp.id = callerOrigin.domain();
 
     // Step 8-10.
-    // Most of the jobs are done by bindings. However, we can't know if the JSValue of options.pubKeyCredParams
-    // is empty or not. Return NotSupportedError as long as it is empty.
+    // Most of the jobs are done by bindings.
     if (options.pubKeyCredParams.isEmpty()) {
-        promise.reject(Exception { NotSupportedError, "Unable to create credential because options.pubKeyCredParams is empty."_s });
-        return;
+        options.pubKeyCredParams.append({ PublicKeyCredentialType::PublicKey, COSE::ES256 });
+        options.pubKeyCredParams.append({ PublicKeyCredentialType::PublicKey, COSE::RS256 });
+    } else {
+        if (notFound != options.pubKeyCredParams.findIf([] (auto& pubKeyCredParam) {
+            return pubKeyCredParam.type != PublicKeyCredentialType::PublicKey;
+        })) {
+            
+            promise.reject(Exception { NotSupportedError, "options.pubKeyCredParams contains unsupported PublicKeyCredentialType value."_s });
+            return;
+        }
     }
 
     // Step 11-12.

Modified: trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h (290514 => 290515)


--- trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h	2022-02-25 18:44:20 UTC (rev 290515)
@@ -76,7 +76,7 @@
     UserEntity user;
 
     BufferSource challenge;
-    Vector<Parameters> pubKeyCredParams;
+    mutable Vector<Parameters> pubKeyCredParams;
 
     std::optional<unsigned> timeout;
     Vector<PublicKeyCredentialDescriptor> excludeCredentials;

Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (290514 => 290515)


--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-02-25 17:23:52 UTC (rev 290514)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-02-25 18:44:20 UTC (rev 290515)
@@ -38,6 +38,7 @@
 // Values
 const int64_t EC2 = 2;
 const int64_t ES256 = -7;
+const int64_t RS256 = -257;
 const int64_t ECDH256 = -25;
 const int64_t P_256 = 1;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to