⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 284532 in webkit


Ignore:
Timestamp:
Oct 20, 2021, 8:01:41 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebKit:
[WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
https://bugs.webkit.org/show_bug.cgi?id=219813
<rdar://problem/72484635>

Patch by John Pascoe <J Pascoe> on 2021-10-20
Reviewed by Brent Fulgham.

Currently, whenever the platform authenticator is within excludedCredentials during makeCredential we
always return NotAllowedError and merely flash a consent screen. This does not match the spec per Step 3.1
of makeCredential (https://w3c.github.io/webauthn/#sctn-op-make-cred). Instead, we should always obtain consent
and return a different error depending on consent was obtained.

A fixme to add this was inadvertently removed in https://bugs.webkit.org/attachment.cgi?id=393180&action=prettypatch

Added api test TestWebKitAPI.WebAuthenticationPanel.LADuplicateCredentialWithConsent

  • UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:

(WebKit::LocalAuthenticator::makeCredential):

Tools:
[WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
https://bugs.webkit.org/show_bug.cgi?id=219813
<rdar://problem/72484635>

Patch by John Pascoe <J Pascoe> on 2021-10-20
Reviewed by Brent Fulgham.

Currently, whenever the platform authenticator is within excludedCredentials during makeCredential we
always return NotAllowedError and merely flash a consent screen. This does not match the spec per Step 3.1
of makeCredential (https://w3c.github.io/webauthn/#sctn-op-make-cred). Instead, we should always obtain consent
and return a different error depending on consent was obtained.

This adds a test to confirm a different path is taken whenever consent is obtained.

  • TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:

(TestWebKitAPI::TEST):

LayoutTests:
WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
https://bugs.webkit.org/show_bug.cgi?id=219813
<rdar://problem/72484635>

Patch by John Pascoe <J Pascoe> on 2021-10-20
Reviewed by Brent Fulgham.

Modify layout tests to reflect different exception returned when consent is provided

  • http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284530 r284532  
     12021-10-20  John Pascoe  <j_pascoe@apple.com>
     2
     3        WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
     4        https://bugs.webkit.org/show_bug.cgi?id=219813
     5        <rdar://problem/72484635>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Modify layout tests to reflect different exception returned when consent is provided
     10
     11        * http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html:
     12        * http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
     13
    1142021-10-20  Alan Bujtas  <zalan@apple.com>
    215
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local-silent.https.html

    r284429 r284532  
    5151        if (window.testRunner)
    5252            testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, testUserEntityBundleBase64);
    53         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.").then(() => {
     53        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    5454            if (window.testRunner)
    5555                testRunner.cleanUpKeychain(testRpId, credentialIDBase64);
     
    8585        if (window.testRunner)
    8686            testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, testUserEntityBundleBase64);
    87         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.").then(() => {
     87        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    8888            if (window.testRunner)
    8989                testRunner.cleanUpKeychain(testRpId, credentialIDBase64);
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local.https.html

    r284429 r284532  
    4949        if (window.testRunner)
    5050            testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, testUserEntityBundleBase64);
    51         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
     51        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    5252            if (window.testRunner)
    5353                testRunner.cleanUpKeychain(testRpId, credentialIDBase64);
     
    8282        if (window.testRunner)
    8383            testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, testUserEntityBundleBase64);
    84         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
     84        return promiseRejects(t, "InvalidStateError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    8585            if (window.testRunner)
    8686                testRunner.cleanUpKeychain(testRpId, credentialIDBase64);
  • trunk/Source/WebKit/ChangeLog

    r284528 r284532  
     12021-10-20  John Pascoe  <j_pascoe@apple.com>
     2        [WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
     3        https://bugs.webkit.org/show_bug.cgi?id=219813
     4        <rdar://problem/72484635>
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Currently, whenever the platform authenticator is within excludedCredentials during makeCredential we
     9        always return NotAllowedError and merely flash a consent screen. This does not match the spec per Step 3.1
     10        of makeCredential (https://w3c.github.io/webauthn/#sctn-op-make-cred). Instead, we should always obtain consent
     11        and return a different error depending on consent was obtained.
     12
     13        A fixme to add this was inadvertently removed in https://bugs.webkit.org/attachment.cgi?id=393180&action=prettypatch
     14
     15        Added api test TestWebKitAPI.WebAuthenticationPanel.LADuplicateCredentialWithConsent
     16
     17        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     18        (WebKit::LocalAuthenticator::makeCredential):
     19
    1202021-10-20  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r284429 r284532  
    228228            return excludeCredentialIds.contains(base64EncodeToString(rawId->data(), rawId->byteLength()));
    229229        })) {
    230             receiveException({ NotAllowedError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s }, WebAuthenticationStatus::LAExcludeCredentialsMatched);
     230            // Obtain consent per Step 3.1
     231            auto callback = [weakThis = WeakPtr { *this }] (LocalAuthenticatorPolicy policy) {
     232                ASSERT(RunLoop::isMain());
     233                if (!weakThis)
     234                    return;
     235
     236                if (policy == LocalAuthenticatorPolicy::Allow)
     237                    weakThis->receiveException({ InvalidStateError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s }, WebAuthenticationStatus::LAExcludeCredentialsMatched);
     238                else
     239                    weakThis->receiveException({ NotAllowedError, "This request has been cancelled by the user."_s });
     240            };
     241            observer()->decidePolicyForLocalAuthenticator(WTFMove(callback));
    231242            return;
    232243        }
  • trunk/Tools/ChangeLog

    r284528 r284532  
     12021-10-20  John Pascoe  <j_pascoe@apple.com>
     2        [WebAuthn] Obtain consent to create new credential when platform authenticator in excludedCredentials
     3        https://bugs.webkit.org/show_bug.cgi?id=219813
     4        <rdar://problem/72484635>
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Currently, whenever the platform authenticator is within excludedCredentials during makeCredential we
     9        always return NotAllowedError and merely flash a consent screen. This does not match the spec per Step 3.1
     10        of makeCredential (https://w3c.github.io/webauthn/#sctn-op-make-cred). Instead, we should always obtain consent
     11        and return a different error depending on consent was obtained.
     12
     13        This adds a test to confirm a different path is taken whenever consent is obtained.
     14
     15        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
     16        (TestWebKitAPI::TEST):
     17
    1182021-10-20  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

    r284429 r284532  
    13831383    ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "", testUserEntityBundleBase64));
    13841384    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     1385    Util::run(&webAuthenticationPanelFailed);
     1386    cleanUpKeychain("");
     1387}
     1388
     1389TEST(WebAuthenticationPanel, LADuplicateCredentialWithConsent)
     1390{
     1391    reset();
     1392    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"web-authentication-make-credential-la-duplicate-credential" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     1393
     1394    auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
     1395    [[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()];
     1396    [[configuration preferences] _setEnabled:NO forExperimentalFeature:webAuthenticationModernExperimentalFeature()];
     1397
     1398    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]);
     1399    auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
     1400    [webView setUIDelegate:delegate.get()];
     1401    [webView focus];
     1402
     1403    ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "", testUserEntityBundleBase64));
     1404
     1405    localAuthenticatorPolicy = _WKLocalAuthenticatorPolicyAllow;
     1406
     1407    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    13851408    Util::run(&webAuthenticationPanelUpdateLAExcludeCredentialsMatched);
    13861409    cleanUpKeychain("");
Note: See TracChangeset for help on using the changeset viewer.