Changeset 254894 in webkit


Ignore:
Timestamp:
Jan 21, 2020 5:25:57 PM (4 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthn] Incorporate more detailed UnknownError messages for LocalAuthenticator
https://bugs.webkit.org/show_bug.cgi?id=191530

Reviewed by Brent Fulgham.

Source/WebKit:

This patch replaces UnknownError messages within LocalAuthenticator with the LOG_ERROR
messages. At the meantime, it enhances MockLocalConnection::getAttestation to return
errors instead of assertions.

  • UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:

(WebKit::LocalAuthenticator::makeCredential):
(WebKit::LocalAuthenticator::continueMakeCredentialAfterUserConsented):
(WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested):
(WebKit::LocalAuthenticator::getAssertion):
(WebKit::LocalAuthenticator::continueGetAssertionAfterUserConsented):

  • UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:

(WebKit::MockLocalConnection::getAttestation const):

LayoutTests:

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r254890 r254894  
     12020-01-21  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Incorporate more detailed UnknownError messages for LocalAuthenticator
     4        https://bugs.webkit.org/show_bug.cgi?id=191530
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
     9
    1102020-01-21  Commit Queue  <commit-queue@webkit.org>
    211
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local.https.html

    r250940 r254894  
    119119            if (window.internals)
    120120                internals.setMockWebAuthenticationConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false } });
    121             return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.");
     121            return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Couldn't attest: The operation couldn't complete.");
    122122        }, "PublicKeyCredential's [[create]] without attestation in a mock local authenticator.");
    123123
     
    141141                testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
    142142            }
    143             return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.").then(() => {
     143            return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Couldn't attest: The operation couldn't complete.").then(() => {
    144144                if (window.testRunner)
    145145                    assert_false(testRunner.keyExistsInKeychain(testRpId, userhandleBase64));
  • trunk/Source/WebKit/ChangeLog

    r254892 r254894  
     12020-01-21  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Incorporate more detailed UnknownError messages for LocalAuthenticator
     4        https://bugs.webkit.org/show_bug.cgi?id=191530
     5
     6        Reviewed by Brent Fulgham.
     7
     8        This patch replaces UnknownError messages within LocalAuthenticator with the LOG_ERROR
     9        messages. At the meantime, it enhances MockLocalConnection::getAttestation to return
     10        errors instead of assertions.
     11
     12        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     13        (WebKit::LocalAuthenticator::makeCredential):
     14        (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserConsented):
     15        (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested):
     16        (WebKit::LocalAuthenticator::getAssertion):
     17        (WebKit::LocalAuthenticator::continueGetAssertionAfterUserConsented):
     18        * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
     19        (WebKit::MockLocalConnection::getAttestation const):
     20
    1212020-01-21  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r253398 r254894  
    132132        if (status && status != errSecItemNotFound) {
    133133            LOG_ERROR("Couldn't query Keychain: %d", status);
    134             receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     134            receiveRespond(ExceptionData { UnknownError, makeString("Couldn't query Keychain: ", status) });
    135135            return;
    136136        }
     
    187187    OSStatus status = SecItemDelete((__bridge CFDictionaryRef)deleteQuery);
    188188    if (status && status != errSecItemNotFound) {
    189         LOG_ERROR("Couldn't detele older credential: %d", status);
    190         receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     189        LOG_ERROR("Couldn't delete older credential: %d", status);
     190        receiveRespond(ExceptionData { UnknownError, makeString("Couldn't delete older credential: ", status) });
    191191        return;
    192192    }
     
    212212    if (error) {
    213213        LOG_ERROR("Couldn't attest: %@", error);
    214         receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     214        receiveRespond(ExceptionData { UnknownError, makeString("Couldn't attest: ", String(error.localizedDescription)) });
    215215        return;
    216216    }
     
    250250        if (status) {
    251251            LOG_ERROR("Couldn't get Credential ID: %d", status);
    252             receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     252            receiveRespond(ExceptionData { UnknownError, makeString("Couldn't get Credential ID: ", status) });
    253253            return;
    254254        }
     
    275275        if (status) {
    276276            LOG_ERROR("Couldn't update the Keychain item: %d", status);
    277             receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     277            receiveRespond(ExceptionData { UnknownError, makeString("Couldn't update the Keychain item: ", status) });
    278278            return;
    279279        }
     
    296296            if (errorRef) {
    297297                LOG_ERROR("Couldn't export the public key: %@", (NSError*)errorRef);
    298                 receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     298                receiveRespond(ExceptionData { UnknownError, makeString("Couldn't export the public key: ", String(((NSError*)errorRef).localizedDescription)) });
    299299                return;
    300300            }
     
    328328            if (errorRef) {
    329329                LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
    330                 receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     330                receiveRespond(ExceptionData { UnknownError, makeString("Couldn't generate the signature: ", String(((NSError*)errorRef).localizedDescription)) });
    331331                return;
    332332            }
     
    380380    if (status && status != errSecItemNotFound) {
    381381        LOG_ERROR("Couldn't query Keychain: %d", status);
    382         receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     382        receiveRespond(ExceptionData { UnknownError, makeString("Couldn't query Keychain: ", status) });
    383383        return;
    384384    }
     
    462462        if (status) {
    463463            LOG_ERROR("Couldn't get the private key reference: %d", status);
    464             receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     464            receiveRespond(ExceptionData { UnknownError, makeString("Couldn't get the private key reference: ", status) });
    465465            return;
    466466        }
     
    476476        if (errorRef) {
    477477            LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
    478             receiveRespond(ExceptionData { UnknownError, "Unknown internal error."_s });
     478            receiveRespond(ExceptionData { UnknownError, makeString("Couldn't generate the signature: ", String(((NSError*)errorRef).localizedDescription)) });
    479479            return;
    480480        }
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm

    r250940 r254894  
    7474        ASSERT(configuration.local);
    7575        if (!configuration.local->acceptAttestation) {
    76             callback(NULL, NULL, [NSError errorWithDomain:NSOSStatusErrorDomain code:-1 userInfo:nil]);
     76            callback(NULL, NULL, [NSError errorWithDomain:@"WebAuthentication" code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"The operation couldn't complete." }]);
    7777            return;
    7878        }
     
    9090            &errorRef
    9191        ));
    92         ASSERT(!errorRef);
     92        if (errorRef) {
     93            callback(NULL, NULL, (NSError *)errorRef);
     94            return;
     95        }
    9396
    9497        // Mock what DeviceIdentity would do.
     
    100103        };
    101104        OSStatus status = SecItemAdd((__bridge CFDictionaryRef)addQuery, NULL);
    102         ASSERT_UNUSED(status, !status);
     105        if (status) {
     106            callback(NULL, NULL, [NSError errorWithDomain:@"WebAuthentication" code:status userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't add the key to the keychain." }]);
     107            return;
     108        }
    103109
    104110        auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)adoptNS([[NSData alloc] initWithBase64EncodedString:configuration.local->userCertificateBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get()));
Note: See TracChangeset for help on using the changeset viewer.