Changeset 276180 in webkit
- Timestamp:
- Apr 16, 2021, 4:52:30 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/webauthn/public-key-credential-create-success-local.https-expected.txt (modified) (2 diffs)
-
LayoutTests/http/wpt/webauthn/public-key-credential-create-success-local.https.html (modified) (3 diffs)
-
LayoutTests/http/wpt/webauthn/public-key-credential-get-success-local.https-expected.txt (modified) (2 diffs)
-
LayoutTests/http/wpt/webauthn/public-key-credential-get-success-local.https.html (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/testing/MockWebAuthenticationConfiguration.h (modified) (2 diffs)
-
Source/WebCore/testing/MockWebAuthenticationConfiguration.idl (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (modified) (7 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm (modified) (5 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalService.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r276178 r276180 1 2021-04-16 Jiewen Tan <jiewen_tan@apple.com> 2 3 Allow using the platform authenticator on non-Touch ID Macs according to Internal requirements 4 https://bugs.webkit.org/show_bug.cgi?id=224639 5 <rdar://74698346> 6 7 Reviewed by Daniel Bates. 8 9 * http/wpt/webauthn/public-key-credential-create-success-local.https-expected.txt: 10 * http/wpt/webauthn/public-key-credential-create-success-local.https.html: 11 * http/wpt/webauthn/public-key-credential-get-success-local.https-expected.txt: 12 * http/wpt/webauthn/public-key-credential-get-success-local.https.html: 13 1 14 2021-04-16 Robert Jenner <jenner@apple.com> 2 15 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-local.https-expected.txt
r272345 r276180 1 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. 1 2 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. 2 3 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. … … 16 17 PASS PublicKeyCredential's [[create]] with duplicate credential in a mock local authenticator. 17 18 PASS PublicKeyCredential's [[create]] with duplicate credential in a mock local authenticator. 2 19 PASS PublicKeyCredential's [[create]] with user presence in a mock local authenticator. 18 20 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-local.https.html
r269420 r276180 6 6 <script src="./resources/cbor.js"></script> 7 7 <script> 8 function checkResult(credential, credentialID, isNoneAttestation = true )8 function checkResult(credential, credentialID, isNoneAttestation = true, isUV = true) 9 9 { 10 10 // Check keychain … … 30 30 const authData = decodeAuthData(attestationObject.authData); 31 31 assert_equals(bytesToHexString(authData.rpIdHash), "49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763"); 32 assert_equals(authData.flags, 69); 32 if (isUV) 33 assert_equals(authData.flags, 69); 34 else 35 assert_equals(authData.flags, 65); 33 36 assert_equals(authData.counter, 0); 34 37 if (isNoneAttestation) … … 345 348 }); 346 349 }, "PublicKeyCredential's [[create]] with duplicate credential in a mock local authenticator. 2"); 350 351 promise_test(async t => { 352 const privateKeyBase64 = await generatePrivateKeyBase64(); 353 const credentialID = await calculateCredentialID(privateKeyBase64); 354 const userhandleBase64 = generateUserhandleBase64(); 355 if (window.internals) 356 internals.setMockWebAuthenticationConfiguration({ 357 local: { 358 userVerification: "presence", 359 acceptAttestation: false, 360 privateKeyBase64: privateKeyBase64, 361 } 362 }); 363 364 const options = { 365 publicKey: { 366 rp: { 367 name: "localhost", 368 }, 369 user: { 370 name: userhandleBase64, 371 id: Base64URL.parse(userhandleBase64), 372 displayName: "Appleseed", 373 }, 374 challenge: Base64URL.parse("MTIzNDU2"), 375 pubKeyCredParams: [{ type: "public-key", alg: -7 }], 376 } 377 }; 378 379 return navigator.credentials.create(options).then(credential => { 380 checkResult(credential, credentialID, true, false); 381 }); 382 }, "PublicKeyCredential's [[create]] with user presence in a mock local authenticator."); 347 383 </script> -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-local.https-expected.txt
r272345 r276180 1 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. 1 2 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. 2 3 CONSOLE MESSAGE: User gesture is not detected. To use the WebAuthn API, call 'navigator.credentials.create' within user activated events. … … 4 5 PASS PublicKeyCredential's [[get]] with minimum options in a mock local authenticator. 5 6 PASS PublicKeyCredential's [[get]] with matched allow credentials in a mock local authenticator. 7 PASS PublicKeyCredential's [[get]] with user presence in a mock local authenticator. 6 8 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-local.https.html
r269360 r276180 5 5 <script src="./resources/util.js"></script> 6 6 <script> 7 function checkResult(credential, credentialID, privateKeyBase64 )7 function checkResult(credential, credentialID, privateKeyBase64, isUV = true) 8 8 { 9 9 if (window.testRunner) … … 21 21 const authData = decodeAuthData(new Uint8Array(credential.response.authenticatorData)); 22 22 assert_equals(bytesToHexString(authData.rpIdHash), "49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763"); 23 assert_equals(authData.flags, 5); 23 if (isUV) 24 assert_equals(authData.flags, 5); 25 else 26 assert_equals(authData.flags, 1); 24 27 assert_equals(authData.counter, 0); 25 28 … … 81 84 }); 82 85 }, "PublicKeyCredential's [[get]] with matched allow credentials in a mock local authenticator."); 86 87 promise_test(async t => { 88 const privateKeyBase64 = await generatePrivateKeyBase64(); 89 const credentialID = await calculateCredentialID(privateKeyBase64); 90 const credentialIDBase64 = base64encode(credentialID); 91 // Default mock configuration. Tests need to override if they need different configuration. 92 if (window.internals) 93 internals.setMockWebAuthenticationConfiguration({ local: { userVerification: "presence", acceptAttestation: false, preferredCredentialIdBase64: credentialIDBase64 } }); 94 95 const options = { 96 publicKey: { 97 challenge: Base64URL.parse("MTIzNDU2") 98 } 99 }; 100 101 if (window.testRunner) 102 testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, testUserEntityBundleBase64); 103 return navigator.credentials.get(options).then(credential => { 104 return checkResult(credential, credentialID, privateKeyBase64, false); 105 }); 106 }, "PublicKeyCredential's [[get]] with user presence in a mock local authenticator."); 83 107 </script> -
trunk/Source/WebCore/ChangeLog
r276177 r276180 1 2021-04-16 Jiewen Tan <jiewen_tan@apple.com> 2 3 Allow using the platform authenticator on non-Touch ID Macs according to Internal requirements 4 https://bugs.webkit.org/show_bug.cgi?id=224639 5 <rdar://74698346> 6 7 Reviewed by Daniel Bates. 8 9 Covered by new tests within existing test files. 10 11 * testing/MockWebAuthenticationConfiguration.h: 12 * testing/MockWebAuthenticationConfiguration.idl: 13 Mock testing support. 14 1 15 2021-04-16 Peng Liu <peng.liu6@apple.com> 2 16 -
trunk/Source/WebCore/testing/MockWebAuthenticationConfiguration.h
r262994 r276180 65 65 No, 66 66 Yes, 67 Cancel 67 Cancel, 68 Presence 68 69 }; 69 70 … … 309 310 WebCore::MockWebAuthenticationConfiguration::UserVerification::No, 310 311 WebCore::MockWebAuthenticationConfiguration::UserVerification::Yes, 311 WebCore::MockWebAuthenticationConfiguration::UserVerification::Cancel 312 WebCore::MockWebAuthenticationConfiguration::UserVerification::Cancel, 313 WebCore::MockWebAuthenticationConfiguration::UserVerification::Presence 312 314 >; 313 315 }; -
trunk/Source/WebCore/testing/MockWebAuthenticationConfiguration.idl
r259680 r276180 65 65 "no", 66 66 "yes", 67 "cancel" 67 "cancel", 68 "presence" 68 69 }; 69 70 -
trunk/Source/WebKit/ChangeLog
r276177 r276180 1 2021-04-16 Jiewen Tan <jiewen_tan@apple.com> 2 3 Allow using the platform authenticator on non-Touch ID Macs according to Internal requirements 4 https://bugs.webkit.org/show_bug.cgi?id=224639 5 <rdar://74698346> 6 7 Reviewed by Daniel Bates. 8 9 * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: 10 (WebKit::LocalAuthenticator::continueMakeCredentialAfterDecidePolicy): 11 (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification): 12 (WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected): 13 (WebKit::LocalAuthenticator::continueGetAssertionAfterUserVerification): 14 Don't set the UserVerification bit if UserVerification is not done. 15 16 * UIProcess/WebAuthentication/Cocoa/LocalConnection.h: 17 * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm: 18 (WebKit::LocalConnection::verifyUser): 19 Only check UserPresence on non-Touch ID Macs. 20 21 * UIProcess/WebAuthentication/Cocoa/LocalService.mm: 22 (WebKit::LocalService::isAvailable): 23 Make the platform authenticator available according to Internal requirements. 24 25 * UIProcess/WebAuthentication/Mock/MockLocalConnection.h: 26 * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm: 27 (WebKit::MockLocalConnection::verifyUser): 28 Mock testing support. 29 30 * UIProcess/WebAuthentication/WebAuthenticationRequestData.cpp: 31 (WebKit::getUserVerificationRequirement): 32 * UIProcess/WebAuthentication/WebAuthenticationRequestData.h: 33 Add a helper for extracting the UserVerification input. 34 1 35 2021-04-16 Peng Liu <peng.liu6@apple.com> 2 36 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm
r274689 r276180 65 65 // See https://www.w3.org/TR/webauthn/#flags. 66 66 const uint8_t makeCredentialFlags = 0b01000101; // UP, UV and AT are set. 67 const uint8_t otherMakeCredentialFlags = 0b01000001; // UP and AT are set. 67 68 const uint8_t getAssertionFlags = 0b00000101; // UP and UV are set. 69 const uint8_t otherGetAssertionFlags = 0b00000001; // UP is set. 68 70 // Credential ID is currently SHA-1 of the corresponding public key. 69 71 const uint16_t credentialIdLength = 20; … … 307 309 weakThis->continueMakeCredentialAfterUserVerification(accessControl.get(), verification, context); 308 310 }; 309 m_connection->verifyUser(creationOptions.rp.id, getClientDataType(requestData().options), accessControlRef, WTFMove(callback));311 m_connection->verifyUser(creationOptions.rp.id, getClientDataType(requestData().options), accessControlRef, getUserVerificationRequirement(requestData().options), WTFMove(callback)); 310 312 } 311 313 … … 426 428 } 427 429 430 auto flags = verification == LocalConnection::UserVerification::Presence ? otherMakeCredentialFlags : makeCredentialFlags; 428 431 // Step 12. 429 432 // Skip Apple Attestation for none attestation. … … 431 434 deleteDuplicateCredential(); 432 435 433 auto authData = buildAuthData(creationOptions.rp.id, makeCredentialFlags, counter, buildAttestedCredentialData(Vector<uint8_t>(aaguidLength, 0), credentialId, cosePublicKey));436 auto authData = buildAuthData(creationOptions.rp.id, flags, counter, buildAttestedCredentialData(Vector<uint8_t>(aaguidLength, 0), credentialId, cosePublicKey)); 434 437 auto attestationObject = buildAttestationObject(WTFMove(authData), "", { }, AttestationConveyancePreference::None); 435 438 receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject)); … … 438 441 439 442 // Step 13. Apple Attestation 440 auto authData = buildAuthData(creationOptions.rp.id, makeCredentialFlags, counter, buildAttestedCredentialData(aaguidVector(), credentialId, cosePublicKey));443 auto authData = buildAuthData(creationOptions.rp.id, flags, counter, buildAttestedCredentialData(aaguidVector(), credentialId, cosePublicKey)); 441 444 auto nsAuthData = toNSData(authData); 442 445 auto callback = [credentialId = WTFMove(credentialId), authData = WTFMove(authData), weakThis = makeWeakPtr(*this)] (NSArray * _Nullable certificates, NSError * _Nullable error) mutable { … … 580 583 weakThis->continueGetAssertionAfterUserVerification(WTFMove(response), verification, context); 581 584 }; 582 m_connection->verifyUser(requestOptions.rpId, getClientDataType(requestData().options), accessControlRef, WTFMove(callback));585 m_connection->verifyUser(requestOptions.rpId, getClientDataType(requestData().options), accessControlRef, getUserVerificationRequirement(requestData().options), WTFMove(callback)); 583 586 } 584 587 … … 594 597 // Step 10. 595 598 auto requestOptions = WTF::get<PublicKeyCredentialRequestOptions>(requestData().options); 596 auto authData = buildAuthData(requestOptions.rpId, getAssertionFlags, counter, { });599 auto authData = buildAuthData(requestOptions.rpId, verification == LocalConnection::UserVerification::Presence ? otherGetAssertionFlags : getAssertionFlags, counter, { }); 597 600 598 601 // Step 11. -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h
r270694 r276180 39 39 class AuthenticatorAssertionResponse; 40 40 enum class ClientDataType : bool; 41 enum class UserVerificationRequirement; 41 42 } 42 43 … … 55 56 No, 56 57 Yes, 57 Cancel 58 Cancel, 59 Presence 58 60 }; 59 61 … … 65 67 66 68 // Overrided by MockLocalConnection. 67 virtual void verifyUser(const String& rpId, WebCore::ClientDataType, SecAccessControlRef, UserVerificationCallback&&);69 virtual void verifyUser(const String& rpId, WebCore::ClientDataType, SecAccessControlRef, WebCore::UserVerificationRequirement, UserVerificationCallback&&); 68 70 virtual void verifyUser(SecAccessControlRef, LAContext *, CompletionHandler<void(UserVerification)>&&); 69 71 virtual RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm
r275966 r276180 30 30 31 31 #import <WebCore/LocalizedStrings.h> 32 #import <WebCore/UserVerificationRequirement.h> 32 33 #import <WebCore/WebAuthenticationConstants.h> 33 34 #import <wtf/BlockPtr.h> … … 61 62 } 62 63 63 void LocalConnection::verifyUser(const String& rpId, ClientDataType type, SecAccessControlRef accessControl, UserVerification Callback&& completionHandler)64 void LocalConnection::verifyUser(const String& rpId, ClientDataType type, SecAccessControlRef accessControl, UserVerificationRequirement uv, UserVerificationCallback&& completionHandler) 64 65 { 65 66 String title = genericTouchIDPromptTitle(); … … 85 86 } 86 87 87 auto reply = makeBlockPtr([context = m_context, completionHandler = WTFMove(completionHandler)] (NSDictionary * , NSError *error) mutable {88 auto reply = makeBlockPtr([context = m_context, completionHandler = WTFMove(completionHandler)] (NSDictionary *information, NSError *error) mutable { 88 89 UserVerification verification = UserVerification::Yes; 89 90 if (error) { … … 93 94 verification = UserVerification::Cancel; 94 95 } 96 if (information[@"UserPresence"]) 97 verification = UserVerification::Presence; 95 98 96 99 // This block can be executed in another thread. … … 102 105 #if USE(APPLE_INTERNAL_SDK) 103 106 // Depending on certain internal requirements, accessControl might not require user verifications. 104 // Hence, here introduces a quirk to force the compatible mode to always require user verifications.107 // Hence, here introduces a quirk to force the compatible mode to require user verifications if necessary. 105 108 if (shouldUseAlternateAttributes()) { 106 [m_context evaluatePolicy:LAPolicyDeviceOwnerAuthentication options:options.get() reply:reply.get()]; 109 if (uv == UserVerificationRequirement::Required || [m_context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]) { 110 [m_context evaluatePolicy:LAPolicyDeviceOwnerAuthentication options:options.get() reply:reply.get()]; 111 return; 112 } 113 114 reply(@{ @"UserPresence": @YES }, nullptr); 107 115 return; 108 116 } -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalService.mm
r275492 r276180 35 35 #import "LocalAuthenticationSoftLink.h" 36 36 37 #if USE(APPLE_INTERNAL_SDK) 38 #import <WebKitAdditions/LocalServiceAdditions.h> 39 #else 40 #define LOCAL_SERVICE_ADDITIONS 41 #endif 42 37 43 namespace WebKit { 38 44 … … 44 50 bool LocalService::isAvailable() 45 51 { 52 LOCAL_SERVICE_ADDITIONS 53 46 54 auto context = adoptNS([allocLAContextInstance() init]); 47 55 NSError *error = nil; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h
r272184 r276180 38 38 39 39 private: 40 void verifyUser(const String&, WebCore::ClientDataType, SecAccessControlRef, UserVerificationCallback&&) final;40 void verifyUser(const String&, WebCore::ClientDataType, SecAccessControlRef, WebCore::UserVerificationRequirement, UserVerificationCallback&&) final; 41 41 void verifyUser(SecAccessControlRef, LAContext *, CompletionHandler<void(UserVerification)>&&) final; 42 42 RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const final; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm
r272184 r276180 47 47 } 48 48 49 void MockLocalConnection::verifyUser(const String&, ClientDataType, SecAccessControlRef, UserVerificationCallback&& callback)49 void MockLocalConnection::verifyUser(const String&, ClientDataType, SecAccessControlRef, WebCore::UserVerificationRequirement, UserVerificationCallback&& callback) 50 50 { 51 51 // Mock async operations. … … 62 62 case MockWebAuthenticationConfiguration::UserVerification::Cancel: 63 63 userVerification = UserVerification::Cancel; 64 break; 65 case MockWebAuthenticationConfiguration::UserVerification::Presence: 66 userVerification = UserVerification::Presence; 67 break; 64 68 } 65 69 … … 83 87 case MockWebAuthenticationConfiguration::UserVerification::Cancel: 84 88 userVerification = UserVerification::Cancel; 89 break; 90 case MockWebAuthenticationConfiguration::UserVerification::Presence: 91 userVerification = UserVerification::Presence; 92 break; 85 93 } 86 94 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.cpp
r258961 r276180 29 29 #if ENABLE(WEB_AUTHN) 30 30 31 #import <WebCore/UserVerificationRequirement.h> 32 31 33 namespace WebKit { 32 34 using namespace WebCore; … … 39 41 } 40 42 43 UserVerificationRequirement getUserVerificationRequirement(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options) 44 { 45 if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options)) { 46 if (auto authenticatorSelection = WTF::get<PublicKeyCredentialCreationOptions>(options).authenticatorSelection) 47 return authenticatorSelection->userVerification; 48 return UserVerificationRequirement::Preferred; 49 } 50 51 return WTF::get<PublicKeyCredentialRequestOptions>(options).userVerification; 52 } 53 41 54 } // namespace WebKit 42 55 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h
r272184 r276180 60 60 61 61 WebCore::ClientDataType getClientDataType(const Variant<WebCore::PublicKeyCredentialCreationOptions, WebCore::PublicKeyCredentialRequestOptions>&); 62 WebCore::UserVerificationRequirement getUserVerificationRequirement(const Variant<WebCore::PublicKeyCredentialCreationOptions, WebCore::PublicKeyCredentialRequestOptions>&); 62 63 63 64 } // namespace WebKit
Note:
See TracChangeset
for help on using the changeset viewer.