Changeset 228444 in webkit
- Timestamp:
- Feb 13, 2018 5:34:21 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 2 deleted
- 29 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228435 r228444 1 2018-02-13 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting 4 https://bugs.webkit.org/show_bug.cgi?id=181946 5 <rdar://problem/37258262> 6 7 Reviewed by Chris Dumez. 8 9 * http/wpt/credential-management/credentialscontainer-store-basics.https.html: 10 * http/wpt/webauthn/idl.https.html: 11 * http/wpt/webauthn/public-key-credential-create-failure.https.html: 12 * http/wpt/webauthn/public-key-credential-create-success.https.html: 13 * http/wpt/webauthn/public-key-credential-get-failure.https.html: 14 * http/wpt/webauthn/public-key-credential-get-success.https.html: 15 * http/wpt/webauthn/resources/util.js: 16 1 17 2018-02-13 Antti Koivisto <antti@apple.com> 2 18 -
trunk/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html
r227589 r228444 10 10 chars.push(str.charCodeAt(i)); 11 11 return new Uint8Array(chars); 12 } 13 function hexStringToUint8Array(hexString) 14 { 15 if (hexString.length % 2 != 0) 16 throw "Invalid hexString"; 17 var arrayBuffer = new Uint8Array(hexString.length / 2); 18 19 for (var i = 0; i < hexString.length; i += 2) { 20 var byteValue = parseInt(hexString.substr(i, 2), 16); 21 if (byteValue == NaN) 22 throw "Invalid hexString"; 23 arrayBuffer[i/2] = byteValue; 24 } 25 26 return arrayBuffer; 12 27 } 13 28 … … 27 42 } 28 43 }; 44 // A mock attestation object 45 internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff')); 46 const credential = await navigator.credentials.create(options); 29 47 30 const credential = await navigator.credentials.create(options);31 48 return promise_rejects(t, "NotSupportedError", 32 49 navigator.credentials.store(credential)); -
trunk/LayoutTests/http/wpt/webauthn/idl.https.html
r227589 r228444 50 50 } 51 51 }; 52 // A mock attestation object 53 internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff')); 52 54 createdCredential = await navigator.credentials.create(creationOptions); 53 55 … … 58 60 } 59 61 }; 62 // A mock assertion return bundle. 63 internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03')); 60 64 requestedCredential = await navigator.credentials.get(requestOptions); 61 65 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html
r227382 r228444 21 21 } 22 22 }; 23 internals.mockCredentialsMessenger.setDidTimeOut(); 24 23 25 return promise_rejects(t, "NotAllowedError", 24 26 navigator.credentials.create(options)); … … 65 67 }, "PublicKeyCredential's [[create]] with an empty pubKeyCredParams"); 66 68 67 // This test is targeting to the dummy authenticator, which always cancel the operation68 // when user.displayName = "John".69 69 promise_test(function(t) { 70 70 const options = { … … 83 83 } 84 84 }; 85 internals.mockCredentialsMessenger.setDidUserCancel(); 86 85 87 return promise_rejects(t, "NotAllowedError", 86 88 navigator.credentials.create(options)); -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html
r227589 r228444 5 5 <script src="./resources/util.js"></script> 6 6 <script> 7 // The following test is specifically tuned for current dummy authenticator.8 7 promise_test(function(t) { 9 8 const options = { … … 21 20 } 22 21 }; 22 // A mock attestation object 23 internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff')); 23 24 24 25 return navigator.credentials.create(options).then(function(credential) { … … 27 28 assert_equals(bytesToHexString(credential.rawId), 'ff'); 28 29 assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.create","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}'); 29 // This field is completely fake 0x00*43 | 0x0001ff | SHA-256 hash of the clientDataJSON 30 assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff3374b98316b38046727a770b8e95c4580a292b9e2f4bb44a250a5402d6d3783a'); 30 assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff'); 31 31 try { 32 32 assert_throws("NotSupportedError", credential.getClientExtensionResults()); -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html
r227589 r228444 12 12 } 13 13 }; 14 internals.mockCredentialsMessenger.setDidTimeOut(); 15 14 16 return promise_rejects(t, "NotAllowedError", 15 17 navigator.credentials.get(options)); … … 27 29 }, "PublicKeyCredential's [[get]] with a mismatched RP ID"); 28 30 29 // This test is targeting to the dummy authenticator, which always cancel the operation30 // when allowCredentials is not empty.31 31 promise_test(function(t) { 32 32 const options = { … … 36 36 } 37 37 }; 38 internals.mockCredentialsMessenger.setDidUserCancel(); 39 38 40 return promise_rejects(t, "NotAllowedError", 39 41 navigator.credentials.get(options)); -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html
r227589 r228444 12 12 } 13 13 }; 14 // A mock assertion return bundle. 15 internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03')); 14 16 15 17 return navigator.credentials.get(options).then(function(credential) { 16 const clientDataJsonHash = '577cc24b64b3dd011c61a8efb240aee7e77acc3c144d6dfbe097c6a208bb6d49'; 17 18 assert_equals(credential.id, 'V3zCS2Sz3QEcYajvskCu5-d6zDwUTW374JfGogi7bUk'); 18 assert_equals(credential.id, 'AA'); 19 19 assert_equals(credential.type, 'public-key'); 20 assert_equals(bytesToHexString(credential.rawId), clientDataJsonHash);20 assert_equals(bytesToHexString(credential.rawId), '00'); 21 21 assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.get","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}'); 22 // This field is completely fake 0x00*43 | 0x0001ff | SHA-256 hash of the clientDataJSON 23 assert_equals(bytesToHexString(credential.response.authenticatorData), clientDataJsonHash); 24 assert_equals(bytesToHexString(credential.response.signature), clientDataJsonHash); 25 assert_equals(bytesToHexString(credential.response.userHandle), clientDataJsonHash); 22 assert_equals(bytesToHexString(credential.response.authenticatorData), '01'); 23 assert_equals(bytesToHexString(credential.response.signature), '02'); 24 assert_equals(bytesToHexString(credential.response.userHandle), '03'); 26 25 try { 27 26 assert_throws("NotSupportedError", credential.getClientExtensionResults()); -
trunk/LayoutTests/http/wpt/webauthn/resources/util.js
r227382 r228444 44 44 } 45 45 }; 46 47 function hexStringToUint8Array(hexString) 48 { 49 if (hexString.length % 2 != 0) 50 throw "Invalid hexString"; 51 var arrayBuffer = new Uint8Array(hexString.length / 2); 52 53 for (var i = 0; i < hexString.length; i += 2) { 54 var byteValue = parseInt(hexString.substr(i, 2), 16); 55 if (byteValue == NaN) 56 throw "Invalid hexString"; 57 arrayBuffer[i/2] = byteValue; 58 } 59 60 return arrayBuffer; 61 } -
trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt
r227007 r228444 2 2 PASS navigator.credentials.create() with no argument. 3 3 PASS navigator.credentials.create() with empty argument. 4 FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is notsupported."5 FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is notsupported."6 FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is notsupported." ("NotSupportedError") expected object "TypeError" ("TypeError")7 FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is notsupported."8 FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is notsupported." ("NotSupportedError") expected object "TypeError" ("TypeError")4 FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported." 5 FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported." 6 FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError") 7 FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported." 8 FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError") 9 9 PASS navigator.credentials.create() with bogus publicKey data 10 10 FAIL navigator.credentials.create() returns PublicKeyCredential promise_test: Unhandled rejection with value: object "TypeError: Member PublicKeyCredentialCreationOptions.pubKeyCredParams is required and must be an instance of sequence" 11 11 PASS navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData 12 FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is notsupported." ("NotSupportedError") expected object "TypeError" ("TypeError")12 FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError") 13 13 PASS navigator.credentials.create() with bogus federated and publicKey data 14 14 PASS navigator.credentials.create() with bogus password and publicKey data -
trunk/Source/WebCore/ChangeLog
r228441 r228444 1 2018-02-13 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting 4 https://bugs.webkit.org/show_bug.cgi?id=181946 5 <rdar://problem/37258262> 6 7 Reviewed by Chris Dumez. 8 9 This patch changes the original async model from a work queue to IPC between WebProcess 10 and UIProcess. Since all authenticator operations must be handled in the UIProcess due 11 to sandboxing, this message passing IPC async model then surpasses the original multi 12 threading model. To cooperate that, a CredentialsMessenger class is then created and 13 all task dispatching code is moved thre. 14 15 As an improvement over existing code, static functions from PublicKeyCredential are 16 moved to AuthenticatorManager. AuthenticatorManager is made as a singleton such that 17 when static functions are called, they could reach the CredentialsMessenger to interact 18 with UIProccess. CredentialsMessenger and AuthenticatorManager are separated so later 19 on when other Credential types are created, they can reuse the same IPC messenger. 20 21 What's more, a mock CredentialsMessenger is then created to mock behaviors of UIProcess 22 for testing purpose. 23 24 Covered by existing tests. 25 26 * DerivedSources.make: 27 * Modules/credentialmanagement/BasicCredential.h: 28 * Modules/credentialmanagement/CredentialsContainer.cpp: 29 (WebCore::CredentialsContainer::CredentialsContainer): 30 (WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors): 31 (WebCore::CredentialsContainer::get): 32 (WebCore::CredentialsContainer::isCreate): 33 (WebCore::CredentialsContainer::PendingPromise::PendingPromise): Deleted. 34 (WebCore::CredentialsContainer::dispatchTask): Deleted. 35 * Modules/credentialmanagement/CredentialsContainer.h: 36 (WebCore::CredentialsContainer::PendingPromise::create): Deleted. 37 * Modules/credentialmanagement/CredentialsMessenger.cpp: Added. 38 (WebCore::CredentialsMessenger::exceptionReply): 39 (WebCore::CredentialsMessenger::addCreationCompletionHandler): 40 (WebCore::CredentialsMessenger::takeCreationCompletionHandler): 41 (WebCore::CredentialsMessenger::addRequestCompletionHandler): 42 (WebCore::CredentialsMessenger::takeRequestCompletionHandler): 43 (WebCore::CredentialsMessenger::addQueryCompletionHandler): 44 (WebCore::CredentialsMessenger::takeQueryCompletionHandler): 45 (WebCore::getIdFromAttestationObject): 46 * Modules/credentialmanagement/CredentialsMessenger.h: Added. 47 (WebCore::CreationReturnBundle::CreationReturnBundle): 48 (WebCore::AssertionReturnBundle::AssertionReturnBundle): 49 (WebCore::CredentialsMessenger::weakPtrFactory const): 50 * Modules/webauthn/Authenticator.cpp: Removed. 51 * Modules/webauthn/Authenticator.h: Removed. 52 * Modules/webauthn/AuthenticatorManager.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp. 53 (WebCore::AuthenticatorManagerInternal::produceClientDataJson): 54 (WebCore::AuthenticatorManagerInternal::produceClientDataJsonHash): 55 (WebCore::AuthenticatorManagerInternal::initTimer): 56 (WebCore::AuthenticatorManagerInternal::didTimerFire): 57 (WebCore::AuthenticatorManager::singleton): 58 (WebCore::AuthenticatorManager::setMessenger): 59 (WebCore::AuthenticatorManager::create const): 60 (WebCore::AuthenticatorManager::discoverFromExternalSource const): 61 * Modules/webauthn/AuthenticatorManager.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 62 * Modules/webauthn/AuthenticatorResponse.h: 63 * Modules/webauthn/PublicKeyCredential.cpp: 64 (WebCore::PublicKeyCredentialInternal::produceClientDataJson): Deleted. 65 (WebCore::PublicKeyCredentialInternal::produceClientDataJsonHash): Deleted. 66 (WebCore::PublicKeyCredentialInternal::getIdFromAttestationObject): Deleted. 67 (WebCore::PublicKeyCredential::collectFromCredentialStore): Deleted. 68 (WebCore::PublicKeyCredential::discoverFromExternalSource): Deleted. 69 (WebCore::PublicKeyCredential::store): Deleted. 70 (WebCore::PublicKeyCredential::create): Deleted. 71 (WebCore::PublicKeyCredential::rawId const): Deleted. 72 (WebCore::PublicKeyCredential::response const): Deleted. 73 * Modules/webauthn/PublicKeyCredential.h: 74 * Sources.txt: 75 * WebCore.xcodeproj/project.pbxproj: 76 * testing/Internals.cpp: 77 (WebCore::Internals::Internals): 78 (WebCore::Internals::mockCredentialsMessenger const): 79 * testing/Internals.h: 80 * testing/Internals.idl: 81 * testing/MockCredentialsMessenger.cpp: Added. 82 (WebCore::MockCredentialsMessenger::setAttestationObject): 83 (WebCore::MockCredentialsMessenger::setAssertionReturnBundle): 84 (WebCore::MockCredentialsMessenger::makeCredential): 85 (WebCore::MockCredentialsMessenger::getAssertion): 86 (WebCore::MockCredentialsMessenger::makeCredentialReply): 87 (WebCore::MockCredentialsMessenger::getAssertionReply): 88 * testing/MockCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 89 * testing/MockCredentialsMessenger.idl: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 90 1 91 2018-02-13 Zalan Bujtas <zalan@apple.com> 2 92 -
trunk/Source/WebCore/DerivedSources.make
r228427 r228444 948 948 $(WebCore)/testing/MockCDMFactory.idl \ 949 949 $(WebCore)/testing/MockContentFilterSettings.idl \ 950 $(WebCore)/testing/MockCredentialsMessenger.idl \ 950 951 $(WebCore)/testing/MockPageOverlay.idl \ 951 952 $(WebCore)/testing/MockPaymentAddress.idl \ -
trunk/Source/WebCore/Modules/credentialmanagement/BasicCredential.h
r227764 r228444 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include <wtf/ ThreadSafeRefCounted.h>30 #include <wtf/RefCounted.h> 31 31 #include <wtf/TypeCasts.h> 32 32 #include <wtf/text/WTFString.h> … … 34 34 namespace WebCore { 35 35 36 class BasicCredential : public ThreadSafeRefCounted<BasicCredential> {36 class BasicCredential : public RefCounted<BasicCredential> { 37 37 public: 38 38 enum class Type { -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
r227764 r228444 31 31 32 32 #include "AbortSignal.h" 33 #include "AuthenticatorManager.h" 33 34 #include "CredentialCreationOptions.h" 34 35 #include "CredentialRequestOptions.h" 35 36 #include "Document.h" 36 37 #include "ExceptionOr.h" 37 #include "JSBasicCredential.h" 38 #include "PublicKeyCredential.h" 38 #include "JSDOMPromiseDeferred.h" 39 39 #include "SecurityOrigin.h" 40 #include <wtf/MainThread.h>41 40 42 41 namespace WebCore { 43 42 44 CredentialsContainer::PendingPromise::PendingPromise(Ref<DeferredPromise>&& promise, std::unique_ptr<Timer>&& timer) 45 : promise(WTFMove(promise)) 46 , timer(WTFMove(timer)) 43 CredentialsContainer::CredentialsContainer(WeakPtr<Document>&& document) 44 : m_document(WTFMove(document)) 47 45 { 48 46 } 49 47 50 CredentialsContainer::PendingPromise::PendingPromise(Ref<DeferredPromise>&& promise)51 : promise(WTFMove(promise))52 {53 }54 55 CredentialsContainer::CredentialsContainer(WeakPtr<Document>&& document)56 : m_document(WTFMove(document))57 , m_workQueue(WorkQueue::create("com.apple.WebKit.CredentialQueue"))58 {59 }60 61 // The following implements https://w3c.github.io/webappsec-credential-management/#same-origin-with-its-ancestors62 // as of 14 November 2017.63 48 bool CredentialsContainer::doesHaveSameOriginAsItsAncestors() 64 49 { 50 // The following implements https://w3c.github.io/webappsec-credential-management/#same-origin-with-its-ancestors 51 // as of 14 November 2017. 65 52 if (!m_document) 66 53 return false; … … 74 61 } 75 62 76 // FIXME(181946): Since the underlying authenticator model is not clear at this moment, the timer is moved to CredentialsContainer such that77 // timer can stay with main thread and therefore can easily time out activities on the work queue.78 // FIXME(181945): The usages of AbortSignal are also moved here for the very same reason. Also the AbortSignal is kind of bogus at this moment79 // since it doesn't support observers (or other means) to trigger the actual abort action. Enhancement to AbortSignal is needed.80 template<typename OperationType>81 void CredentialsContainer::dispatchTask(OperationType&& operation, Ref<DeferredPromise>&& promise, std::optional<unsigned long> timeOutInMs)82 {83 ASSERT(isMainThread());84 if (!m_document)85 return;86 87 auto* promiseIndex = promise.ptr();88 auto weakThis = m_weakPtrFactory.createWeakPtr(*this);89 // FIXME(181947): We should probably trim timeOutInMs to some max allowable number.90 if (timeOutInMs) {91 auto pendingPromise = PendingPromise::create(WTFMove(promise), std::make_unique<Timer>([promiseIndex, weakThis] () {92 ASSERT(isMainThread());93 if (weakThis) {94 // A lock should not be needed as all callbacks are executed in the main thread.95 if (auto promise = weakThis->m_pendingPromises.take(promiseIndex))96 promise.value()->promise->reject(Exception { NotAllowedError });97 }98 }));99 pendingPromise->timer->startOneShot(Seconds(timeOutInMs.value() / 1000.0));100 m_pendingPromises.add(promiseIndex, WTFMove(pendingPromise));101 } else102 m_pendingPromises.add(promiseIndex, PendingPromise::create(WTFMove(promise)));103 104 auto task = [promiseIndex, weakThis, origin = m_document->securityOrigin().isolatedCopy(), isSameOriginWithItsAncestors = doesHaveSameOriginAsItsAncestors(), operation = WTFMove(operation)] () {105 auto result = operation(origin, isSameOriginWithItsAncestors);106 callOnMainThread([promiseIndex, weakThis, result = WTFMove(result)] () mutable {107 if (weakThis) {108 // A lock should not be needed as all callbacks are executed in the main thread.109 if (auto promise = weakThis->m_pendingPromises.take(promiseIndex)) {110 if (result.hasException())111 promise.value()->promise->reject(result.releaseException());112 else113 promise.value()->promise->resolve<IDLNullable<IDLInterface<BasicCredential>>>(result.returnValue().get());114 }115 }116 });117 };118 m_workQueue->dispatch(WTFMove(task));119 }120 121 63 void CredentialsContainer::get(CredentialRequestOptions&& options, Ref<DeferredPromise>&& promise) 122 64 { 123 65 // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-request as of 4 August 2017 124 66 // with enhancement from 14 November 2017 Editor's Draft. 125 // FIXME: Optional options are passed with no contents. It should be std::optional. 126 if ((!options.signal && !options.publicKey) || !m_document) { 67 if (!m_document) { 127 68 promise->reject(Exception { NotSupportedError }); 128 69 return; 129 70 } 130 71 if (options.signal && options.signal->aborted()) { 131 promise->reject(Exception { AbortError });72 promise->reject(Exception { AbortError, ASCIILiteral("Aborted by AbortSignal.") }); 132 73 return; 133 74 } … … 139 80 // be requested from [[discoverFromExternalSource]]. 140 81 if (!options.publicKey) { 141 promise->reject(Exception { NotSupportedError });82 promise->reject(Exception { NotSupportedError, ASCIILiteral("Only PublicKeyCredential is supported.") }); 142 83 return; 143 84 } 144 85 145 auto timeout = options.publicKey->timeout; 146 auto operation = [options = WTFMove(options.publicKey.value())] (const SecurityOrigin& origin, bool isSameOriginWithItsAncestors) { 147 return PublicKeyCredential::discoverFromExternalSource(origin, options, isSameOriginWithItsAncestors); 148 }; 149 dispatchTask(WTFMove(operation), WTFMove(promise), timeout); 86 // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess. 87 AuthenticatorManager::singleton().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise)); 150 88 } 151 89 152 90 void CredentialsContainer::store(const BasicCredential&, Ref<DeferredPromise>&& promise) 153 91 { 154 promise->reject(Exception { NotSupportedError });92 promise->reject(Exception { NotSupportedError, ASCIILiteral("Not implemented.") }); 155 93 } 156 94 … … 159 97 // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-create as of 4 August 2017 160 98 // with enhancement from 14 November 2017 Editor's Draft. 161 // FIXME: Optional options are passed with no contents. It should be std::optional. 162 if ((!options.signal && !options.publicKey) || !m_document) { 99 if (!m_document) { 163 100 promise->reject(Exception { NotSupportedError }); 164 101 return; 165 102 } 166 103 if (options.signal && options.signal->aborted()) { 167 promise->reject(Exception { AbortError });104 promise->reject(Exception { AbortError, ASCIILiteral("Aborted by AbortSignal.") }); 168 105 return; 169 106 } … … 171 108 ASSERT(m_document->isSecureContext()); 172 109 173 // Step 3- 4. Shortcut as we only support one kind of credentials.110 // Step 3-7. Shortcut as we only support one kind of credentials. 174 111 if (!options.publicKey) { 175 promise->reject(Exception { NotSupportedError });112 promise->reject(Exception { NotSupportedError, ASCIILiteral("Only PublicKeyCredential is supported.") }); 176 113 return; 177 114 } 178 115 179 auto timeout = options.publicKey->timeout; 180 // Step 5-7. 181 auto operation = [options = WTFMove(options.publicKey.value())] (const SecurityOrigin& origin, bool isSameOriginWithItsAncestors) { 182 // Shortcut as well. 183 return PublicKeyCredential::create(origin, options, isSameOriginWithItsAncestors); 184 }; 185 dispatchTask(WTFMove(operation), WTFMove(promise), timeout); 116 // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess. 117 AuthenticatorManager::singleton().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise)); 186 118 } 187 119 188 120 void CredentialsContainer::preventSilentAccess(Ref<DeferredPromise>&& promise) const 189 121 { 190 promise->reject(Exception { NotSupportedError });122 promise->reject(Exception { NotSupportedError, ASCIILiteral("Not implemented.") }); 191 123 } 192 124 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
r227764 r228444 29 29 #if ENABLE(WEB_AUTHN) 30 30 31 #include "JSDOMPromiseDeferred.h"32 #include "Timer.h"33 #include <wtf/Function.h>34 31 #include <wtf/RefCounted.h> 35 32 #include <wtf/WeakPtr.h> 36 #include <wtf/WorkQueue.h>37 33 38 34 namespace WebCore { 39 35 40 36 class BasicCredential; 37 class DeferredPromise; 41 38 class Document; 42 39 … … 60 57 61 58 bool doesHaveSameOriginAsItsAncestors(); 62 template<typename OperationType>63 void dispatchTask(OperationType&&, Ref<DeferredPromise>&&, std::optional<unsigned long> timeOutInMs = std::nullopt);64 59 65 60 WeakPtr<Document> m_document; 66 Ref<WorkQueue> m_workQueue;67 WeakPtrFactory<CredentialsContainer> m_weakPtrFactory;68 69 // Bundle promise and timer, such that the timer can70 // times out the corresponding promsie.71 struct PendingPromise : public RefCounted<PendingPromise> {72 static Ref<PendingPromise> create(Ref<DeferredPromise>&& promise, std::unique_ptr<Timer>&& timer)73 {74 return adoptRef(*new PendingPromise(WTFMove(promise), WTFMove(timer)));75 }76 static Ref<PendingPromise> create(Ref<DeferredPromise>&& promise)77 {78 return adoptRef(*new PendingPromise(WTFMove(promise)));79 }80 81 private:82 PendingPromise(Ref<DeferredPromise>&&, std::unique_ptr<Timer>&&);83 PendingPromise(Ref<DeferredPromise>&&);84 85 public:86 Ref<DeferredPromise> promise;87 std::unique_ptr<Timer> timer;88 };89 HashMap<DeferredPromise*, Ref<PendingPromise>> m_pendingPromises;90 61 }; 91 62 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorManager.h
r228442 r228444 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include < JavaScriptCore/ArrayBuffer.h>31 #include <wtf/ ThreadSafeRefCounted.h>32 #include <wtf/ TypeCasts.h>30 #include <wtf/Forward.h> 31 #include <wtf/Noncopyable.h> 32 #include <wtf/WeakPtr.h> 33 33 34 34 namespace WebCore { 35 35 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 36 class AbortSignal; 37 class CredentialsMessenger; 38 class DeferredPromise; 39 class SecurityOrigin; 40 41 struct PublicKeyCredentialCreationOptions; 42 struct PublicKeyCredentialRequestOptions; 43 44 class AuthenticatorManager { 45 WTF_MAKE_NONCOPYABLE(AuthenticatorManager); 46 friend class NeverDestroyed<AuthenticatorManager>; 37 47 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 48 WEBCORE_EXPORT static AuthenticatorManager& singleton(); 49 WEBCORE_EXPORT void setMessenger(CredentialsMessenger&); 42 50 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 45 46 virtual Type type() const = 0; 47 48 ArrayBuffer* clientDataJSON() const; 51 // The following methods implement static methods of PublicKeyCredential. 52 void create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, Ref<DeferredPromise>&&) const; 53 void discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, Ref<DeferredPromise>&&) const; 49 54 50 55 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 56 AuthenticatorManager() = default; 57 58 WeakPtr<CredentialsMessenger> m_messenger; 52 59 }; 53 60 54 61 } // namespace WebCore 55 62 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \59 SPECIALIZE_TYPE_TRAITS_END()60 61 63 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h
r228218 r228444 29 29 30 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ ThreadSafeRefCounted.h>31 #include <wtf/RefCounted.h> 32 32 #include <wtf/TypeCasts.h> 33 33 34 34 namespace WebCore { 35 35 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {36 class AuthenticatorResponse : public RefCounted<AuthenticatorResponse> { 37 37 public: 38 38 enum class Type { -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
r227764 r228444 29 29 #if ENABLE(WEB_AUTHN) 30 30 31 #include "Authenticator.h"32 #include "AuthenticatorResponse.h"33 31 #include "JSDOMPromiseDeferred.h" 34 #include "PublicKeyCredentialCreationOptions.h"35 #include "PublicKeyCredentialRequestOptions.h"36 #include "SecurityOrigin.h"37 #include <pal/crypto/CryptoDigest.h>38 #include <wtf/CurrentTime.h>39 #include <wtf/JSONValues.h>40 32 #include <wtf/text/Base64.h> 41 33 42 34 namespace WebCore { 43 44 namespace PublicKeyCredentialInternal {45 46 // The layout of attestation object: https://www.w3.org/TR/webauthn/#attestation-object as of 5 December 2017.47 // Here is a summary before CredentialID in the layout. All lengths are fixed.48 // RP ID hash (32) || FLAGS (1) || COUNTER (4) || AAGUID (16) || L (2) || CREDENTIAL ID (?) || ...49 static constexpr size_t CredentialIdLengthOffset = 43;50 51 enum class ClientDataType {52 Create,53 Get54 };55 56 // FIXME(181948): Add token binding ID and extensions.57 static Ref<ArrayBuffer> produceClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin)58 {59 auto object = JSON::Object::create();60 switch (type) {61 case ClientDataType::Create:62 object->setString(ASCIILiteral("type"), ASCIILiteral("webauthn.create"));63 break;64 case ClientDataType::Get:65 object->setString(ASCIILiteral("type"), ASCIILiteral("webauthn.get"));66 break;67 }68 object->setString(ASCIILiteral("challenge"), WTF::base64URLEncode(challenge.data(), challenge.length()));69 object->setString(ASCIILiteral("origin"), origin.toRawString());70 // FIXME: This might be platform dependent.71 object->setString(ASCIILiteral("hashAlgorithm"), ASCIILiteral("SHA-256"));72 73 auto utf8JSONString = object->toJSONString().utf8();74 return ArrayBuffer::create(utf8JSONString.data(), utf8JSONString.length());75 }76 77 static Vector<uint8_t> produceClientDataJsonHash(const Ref<ArrayBuffer>& clientDataJson)78 {79 auto crypto = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256);80 crypto->addBytes(clientDataJson->data(), clientDataJson->byteLength());81 return crypto->computeHash();82 }83 84 static RefPtr<ArrayBuffer> getIdFromAttestationObject(const Vector<uint8_t>& attestationObject)85 {86 // The byte length of L is 2.87 if (attestationObject.size() < CredentialIdLengthOffset + 2)88 return nullptr;89 size_t length = (attestationObject[CredentialIdLengthOffset] << 8) + attestationObject[CredentialIdLengthOffset + 1];90 if (attestationObject.size() < CredentialIdLengthOffset + 2 + length)91 return nullptr;92 return ArrayBuffer::create(attestationObject.data() + CredentialIdLengthOffset + 2, length);93 }94 95 } // namespace PublicKeyCredentialInternal96 35 97 36 PublicKeyCredential::PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response) … … 100 39 , m_response(WTFMove(response)) 101 40 { 102 }103 104 Vector<Ref<BasicCredential>> PublicKeyCredential::collectFromCredentialStore(PublicKeyCredentialRequestOptions&&, bool)105 {106 return { };107 }108 109 ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors)110 {111 using namespace PublicKeyCredentialInternal;112 113 // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.114 // FIXME: Extensions are not supported yet. Skip Step 8-9.115 // Step 1, 3-4, 13, 16 are handled by the caller, including options sanitizing, timer and abort signal.116 // Step 2.117 if (!sameOriginWithAncestors)118 return Exception { NotAllowedError };119 120 // Step 5-7.121 // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.122 // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable123 // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.124 if (!options.rpId.isEmpty() && !(callerOrigin.host() == options.rpId))125 return Exception { SecurityError };126 if (options.rpId.isEmpty())127 options.rpId = callerOrigin.host();128 129 // Step 10-12.130 auto clientDataJson = produceClientDataJson(ClientDataType::Get, options.challenge, callerOrigin);131 auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);132 133 // Step 14-15, 17-19.134 // Only platform attachments will be supported at this stage. Assuming one authenticator per device.135 // Also, resident keys, user verifications and direct attestation are enforced at this tage.136 // For better performance, no filtering is done here regarding to options.excludeCredentials.137 // What's more, user cancellations effectively means NotAllowedError. Therefore, the below call138 // will only returns either an exception or a PublicKeyCredential ref.139 // FIXME(181946): The following operation might need to perform async.140 auto result = Authenticator::singleton().getAssertion(options.rpId, clientDataJsonHash, options.allowCredentials);141 if (result.hasException())142 return result.releaseException();143 144 auto bundle = result.releaseReturnValue();145 return ExceptionOr<RefPtr<BasicCredential>>(PublicKeyCredential::create(WTFMove(bundle.credentialID), AuthenticatorAssertionResponse::create(WTFMove(clientDataJson), WTFMove(bundle.authenticatorData), WTFMove(bundle.signature), WTFMove(bundle.userHandle))));146 }147 148 RefPtr<BasicCredential> PublicKeyCredential::store(RefPtr<BasicCredential>&&, bool)149 {150 return nullptr;151 }152 153 ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors)154 {155 using namespace PublicKeyCredentialInternal;156 157 // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.158 // FIXME: Extensions are not supported yet. Skip Step 11-12.159 // Step 1, 3-4, 16-17 are handled by the caller, including options sanitizing, timer and abort signal.160 // Step 2.161 if (!sameOriginWithAncestors)162 return Exception { NotAllowedError };163 164 // Step 5-7.165 // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.166 // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable167 // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.168 if (!options.rp.id.isEmpty() && !(callerOrigin.host() == options.rp.id))169 return Exception { SecurityError };170 if (options.rp.id.isEmpty())171 options.rp.id = callerOrigin.host();172 173 // Step 8-10.174 // Most of the jobs are done by bindings. However, we can't know if the JSValue of options.pubKeyCredParams175 // is empty or not. Return NotSupportedError as long as it is empty.176 if (options.pubKeyCredParams.isEmpty())177 return Exception { NotSupportedError };178 179 // Step 13-15.180 auto clientDataJson = produceClientDataJson(ClientDataType::Create, options.challenge, callerOrigin);181 auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);182 183 // Step 18-21.184 // Only platform attachments will be supported at this stage. Assuming one authenticator per device.185 // Also, resident keys, user verifications and direct attestation are enforced at this tage.186 // For better performance, no filtering is done here regarding to options.excludeCredentials.187 // What's more, user cancellations effectively means NotAllowedError. Therefore, the below call188 // will only returns either an exception or a PublicKeyCredential ref.189 // FIXME(181946): The following operation might need to perform async.190 auto result = Authenticator::singleton().makeCredential(clientDataJsonHash, options.rp, options.user, options.pubKeyCredParams, options.excludeCredentials);191 if (result.hasException())192 return result.releaseException();193 194 auto attestationObject = result.releaseReturnValue();195 return ExceptionOr<RefPtr<BasicCredential>>(PublicKeyCredential::create(getIdFromAttestationObject(attestationObject), AuthenticatorAttestationResponse::create(WTFMove(clientDataJson), ArrayBuffer::create(attestationObject.data(), attestationObject.size()))));196 }197 198 ArrayBuffer* PublicKeyCredential::rawId() const199 {200 return m_rawId.get();201 }202 203 AuthenticatorResponse* PublicKeyCredential::response() const204 {205 return m_response.get();206 41 } 207 42 -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.h
r228218 r228444 37 37 class AuthenticatorResponse; 38 38 class DeferredPromise; 39 class SecurityOrigin;40 41 struct PublicKeyCredentialCreationOptions;42 struct PublicKeyCredentialRequestOptions;43 39 44 40 class PublicKeyCredential final : public BasicCredential { … … 49 45 } 50 46 51 static Vector<Ref<BasicCredential>> collectFromCredentialStore(PublicKeyCredentialRequestOptions&&, bool); 52 static ExceptionOr<RefPtr<BasicCredential>> discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors); 53 static RefPtr<BasicCredential> store(RefPtr<BasicCredential>&&, bool); 54 static ExceptionOr<RefPtr<BasicCredential>> create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors); 55 56 ArrayBuffer* rawId() const; 57 AuthenticatorResponse* response() const; 47 ArrayBuffer* rawId() const { return m_rawId.get(); } 48 AuthenticatorResponse* response() const { return m_response.get(); } 58 49 // Not support yet. Always throws. 59 50 ExceptionOr<bool> getClientExtensionResults() const; -
trunk/Source/WebCore/Sources.txt
r228427 r228444 46 46 Modules/credentialmanagement/BasicCredential.cpp 47 47 Modules/credentialmanagement/CredentialsContainer.cpp 48 Modules/credentialmanagement/CredentialsMessenger.cpp 48 49 Modules/credentialmanagement/NavigatorCredentials.cpp 49 50 … … 245 246 Modules/webaudio/WaveShaperProcessor.cpp 246 247 247 Modules/webauthn/Authenticator.cpp248 248 Modules/webauthn/AuthenticatorAssertionResponse.cpp 249 249 Modules/webauthn/AuthenticatorAttestationResponse.cpp 250 Modules/webauthn/AuthenticatorManager.cpp 250 251 Modules/webauthn/AuthenticatorResponse.cpp 251 252 Modules/webauthn/PublicKeyCredential.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r228427 r228444 1663 1663 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; }; 1664 1664 57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; }; 1665 57303C4620105D2F00355965 /* Authenticator .h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* Authenticator.h */; };1665 57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorManager.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1666 1666 573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; }; 1667 1667 5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; }; … … 1671 1671 5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; }; 1672 1672 5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; }; 1673 5760827220215A5500116678 /* CredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* CredentialsMessenger.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1674 5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockCredentialsMessenger.h */; }; 1675 5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */; }; 1676 5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082822025679700116678 /* JSMockCredentialsMessenger.h */; }; 1677 5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */; }; 1673 1678 5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; }; 1674 1679 576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; }; … … 8240 8245 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAssertionResponse.h; sourceTree = "<group>"; }; 8241 8246 57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; }; 8242 57303C4320105B3D00355965 /* Authenticator .h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Authenticator.h; sourceTree = "<group>"; };8243 57303C4420105B3D00355965 /* Authenticator .cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Authenticator.cpp; sourceTree = "<group>"; };8247 57303C4320105B3D00355965 /* AuthenticatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorManager.h; sourceTree = "<group>"; }; 8248 57303C4420105B3D00355965 /* AuthenticatorManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorManager.cpp; sourceTree = "<group>"; }; 8244 8249 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; }; 8245 8250 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; }; … … 8260 8265 5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; }; 8261 8266 576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; }; 8267 576082702021513F00116678 /* CredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CredentialsMessenger.h; sourceTree = "<group>"; }; 8268 5760827820244DAB00116678 /* MockCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockCredentialsMessenger.h; sourceTree = "<group>"; }; 8269 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockCredentialsMessenger.cpp; sourceTree = "<group>"; }; 8270 57608280202556F400116678 /* MockCredentialsMessenger.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockCredentialsMessenger.idl; sourceTree = "<group>"; }; 8271 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockCredentialsMessenger.cpp; sourceTree = "<group>"; }; 8272 576082822025679700116678 /* JSMockCredentialsMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockCredentialsMessenger.h; sourceTree = "<group>"; }; 8273 57608293202BA95300116678 /* CredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CredentialsMessenger.cpp; sourceTree = "<group>"; }; 8262 8274 576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; }; 8263 8275 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmEcdhKeyDeriveParams.h; sourceTree = "<group>"; }; … … 16489 16501 A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */, 16490 16502 A19AEA1C1AAA7C4900B52B25 /* MockContentFilterSettings.idl */, 16503 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */, 16504 5760827820244DAB00116678 /* MockCredentialsMessenger.h */, 16505 57608280202556F400116678 /* MockCredentialsMessenger.idl */, 16491 16506 51058AD71D679257009A538C /* MockGamepad.cpp */, 16492 16507 51058AD81D679257009A538C /* MockGamepad.h */, … … 16539 16554 A19AEA1D1AAA806E00B52B25 /* JSMockContentFilterSettings.cpp */, 16540 16555 A19AEA1E1AAA806E00B52B25 /* JSMockContentFilterSettings.h */, 16556 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */, 16557 576082822025679700116678 /* JSMockCredentialsMessenger.h */, 16541 16558 2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */, 16542 16559 2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */, … … 18197 18214 77D510161ED6021B00DA4C87 /* CredentialsContainer.h */, 18198 18215 57D846291FE99F6300CA3682 /* CredentialsContainer.idl */, 18216 57608293202BA95300116678 /* CredentialsMessenger.cpp */, 18217 576082702021513F00116678 /* CredentialsMessenger.h */, 18199 18218 57D846241FE895F500CA3682 /* NavigatorCredentials.cpp */, 18200 18219 57D846261FE895F800CA3682 /* NavigatorCredentials.h */, … … 18225 18244 children = ( 18226 18245 57303BB32006C6ED00355965 /* cbor */, 18227 57303C4420105B3D00355965 /* Authenticator.cpp */,18228 57303C4320105B3D00355965 /* Authenticator.h */,18229 18246 57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */, 18230 18247 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */, … … 18233 18250 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */, 18234 18251 57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */, 18252 57303C4420105B3D00355965 /* AuthenticatorManager.cpp */, 18253 57303C4320105B3D00355965 /* AuthenticatorManager.h */, 18235 18254 57303BD020087A8300355965 /* AuthenticatorResponse.cpp */, 18236 18255 57303BCF20087A8300355965 /* AuthenticatorResponse.h */, … … 26377 26396 538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */, 26378 26397 A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */, 26398 5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */, 26379 26399 538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */, 26380 26400 A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */, … … 26385 26405 A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */, 26386 26406 A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */, 26407 5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */, 26387 26408 51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */, 26388 26409 51058ADE1D6792C1009A538C /* MockGamepadProvider.h in Headers */, … … 26565 26586 E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */, 26566 26587 514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */, 26567 57303C4620105D2F00355965 /* Authenticator.h in Headers */,26568 26588 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */, 26569 26589 57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */, 26590 57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */, 26570 26591 57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */, 26571 26592 A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */, … … 26825 26846 77D5100B1ED5E28800DA4C87 /* CredentialRequestOptions.h in Headers */, 26826 26847 77D510171ED6022200DA4C87 /* CredentialsContainer.h in Headers */, 26848 5760827220215A5500116678 /* CredentialsMessenger.h in Headers */, 26827 26849 51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */, 26828 26850 2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */, … … 30703 30725 CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */, 30704 30726 A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */, 30727 5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */, 30705 30728 2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */, 30706 30729 A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */, … … 30712 30735 A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */, 30713 30736 A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */, 30737 5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */, 30714 30738 51058ADB1D6792C1009A538C /* MockGamepad.cpp in Sources */, 30715 30739 51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */, -
trunk/Source/WebCore/testing/Internals.cpp
r228260 r228444 260 260 #endif 261 261 262 #if ENABLE(WEB_AUTHN) 263 #include "AuthenticatorManager.h" 264 #include "MockCredentialsMessenger.h" 265 #endif 266 262 267 using JSC::CallData; 263 268 using JSC::CallType; … … 526 531 frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*m_mockPaymentCoordinator)); 527 532 } 533 #endif 534 535 #if ENABLE(WEB_AUTHN) 536 m_mockCredentialsMessenger = std::make_unique<MockCredentialsMessenger>(*this); 537 AuthenticatorManager::singleton().setMessenger(*m_mockCredentialsMessenger); 528 538 #endif 529 539 } … … 4376 4386 #endif 4377 4387 4388 #if ENABLE(WEB_AUTHN) 4389 MockCredentialsMessenger& Internals::mockCredentialsMessenger() const 4390 { 4391 return *m_mockCredentialsMessenger; 4392 } 4393 #endif 4394 4378 4395 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r228218 r228444 72 72 class MockCDMFactory; 73 73 class MockContentFilterSettings; 74 class MockCredentialsMessenger; 74 75 class MockPageOverlay; 75 76 class MockPaymentCoordinator; … … 644 645 void testIncomingSyncIPCMessageWhileWaitingForSyncReply(); 645 646 647 #if ENABLE(WEB_AUTHN) 648 MockCredentialsMessenger& mockCredentialsMessenger() const; 649 #endif 650 646 651 private: 647 652 explicit Internals(Document&); … … 669 674 MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr }; 670 675 #endif 676 677 #if ENABLE(WEB_AUTHN) 678 std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger; 679 #endif 671 680 }; 672 681 -
trunk/Source/WebCore/testing/Internals.idl
r227936 r228444 581 581 [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime); 582 582 [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator; 583 }; 583 [Conditional=WEB_AUTHN] readonly attribute MockCredentialsMessenger mockCredentialsMessenger; 584 }; -
trunk/Source/WebCore/testing/MockCredentialsMessenger.h
r228442 r228444 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include <JavaScriptCore/ArrayBuffer.h>31 #include <wtf/ThreadSafeRefCounted.h>32 #include <wtf/ TypeCasts.h>30 #include "BufferSource.h" 31 #include "CredentialsMessenger.h" 32 #include <wtf/Forward.h> 33 33 34 34 namespace WebCore { 35 35 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 36 class Internals; 37 38 class MockCredentialsMessenger final : public CredentialsMessenger { 37 39 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 40 MockCredentialsMessenger(Internals&); 42 41 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 42 void setDidTimeOut() { m_didTimeOut = true; } 43 void setDidUserCancel() { m_didUserCancel = true; } 44 void setAttestationObject(const BufferSource&); 45 void setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle); 45 46 46 virtual Type type() const = 0; 47 48 ArrayBuffer* clientDataJSON() const; 47 void ref(); 48 void deref(); 49 49 50 50 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 51 void makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) final; 52 void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) final; 53 void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&) final; 54 void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) final; 55 56 Internals& m_internals; 57 // All following fields are disposable. 58 bool m_didTimeOut { false }; 59 bool m_didUserCancel { false }; 60 Vector<uint8_t> m_attestationObject; 61 Vector<uint8_t> m_credentialId; 62 Vector<uint8_t> m_authenticatorData; 63 Vector<uint8_t> m_signature; 64 Vector<uint8_t> m_userHandle; 52 65 }; 53 66 54 67 } // namespace WebCore 55 68 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \59 SPECIALIZE_TYPE_TRAITS_END()60 61 69 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebCore/testing/MockCredentialsMessenger.idl
r228442 r228444 24 24 */ 25 25 26 #pragma once 27 28 #if ENABLE(WEB_AUTHN) 29 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ThreadSafeRefCounted.h> 32 #include <wtf/TypeCasts.h> 33 34 namespace WebCore { 35 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 37 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 42 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 45 46 virtual Type type() const = 0; 47 48 ArrayBuffer* clientDataJSON() const; 49 50 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 26 [ 27 Conditional=WEB_AUTHN, 28 NoInterfaceObject, 29 ] interface MockCredentialsMessenger { 30 void setDidTimeOut(); 31 void setDidUserCancel(); 32 void setAttestationObject(BufferSource attestationObject); 33 void setAssertionReturnBundle(BufferSource credentialId, BufferSource authenticatorData, BufferSource signature, BufferSource userHandle); 52 34 }; 53 54 } // namespace WebCore55 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \59 SPECIALIZE_TYPE_TRAITS_END()60 61 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebKit/ChangeLog
r228442 r228444 1 2018-02-13 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting 4 https://bugs.webkit.org/show_bug.cgi?id=181946 5 <rdar://problem/37258262> 6 7 Reviewed by Chris Dumez. 8 9 Dummy WebCredentialsMessenger and WebCredentialsMessengerProxy are crafted to establish 10 a message exchange channel between UIProcess and WebProcess. 11 12 * DerivedSources.make: 13 * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 14 (WebKit::WebCredentialsMessengerProxy::WebCredentialsMessengerProxy): 15 (WebKit::WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy): 16 (WebKit::WebCredentialsMessengerProxy::makeCredential): 17 (WebKit::WebCredentialsMessengerProxy::getAssertion): 18 * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 19 * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in: Added. 20 * UIProcess/WebPageProxy.cpp: 21 (WebKit::m_configurationPreferenceValues): 22 (WebKit::WebPageProxy::reattachToWebProcess): 23 * UIProcess/WebPageProxy.h: 24 * WebKit.xcodeproj/project.pbxproj: 25 * WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 26 (WebKit::WebCredentialsMessenger::WebCredentialsMessenger): 27 (WebKit::WebCredentialsMessenger::~WebCredentialsMessenger): 28 (WebKit::WebCredentialsMessenger::makeCredential): 29 (WebKit::WebCredentialsMessenger::getAssertion): 30 (WebKit::WebCredentialsMessenger::makeCredentialReply): 31 (WebKit::WebCredentialsMessenger::getAssertionReply): 32 * WebProcess/CredentialManagement/WebCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h. 33 * WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in: Added. 34 * WebProcess/WebPage/WebPage.cpp: 35 (WebKit::m_credentialsMessenger): 36 (WebKit::m_cpuLimit): Deleted. 37 * WebProcess/WebPage/WebPage.h: 38 1 39 2018-02-13 Youenn Fablet <youenn@apple.com> 2 40 -
trunk/Source/WebKit/DerivedSources.make
r227939 r228444 44 44 $(WebKit2)/WebProcess/Cache \ 45 45 $(WebKit2)/WebProcess/Cookies \ 46 $(WebKit2)/WebProcess/CredentialManagement \ 46 47 $(WebKit2)/WebProcess/Databases/IndexedDB \ 47 48 $(WebKit2)/WebProcess/FullScreen \ … … 69 70 $(WebKit2)/UIProcess/Automation \ 70 71 $(WebKit2)/UIProcess/Cocoa \ 72 $(WebKit2)/UIProcess/CredentialManagement \ 71 73 $(WebKit2)/UIProcess/Databases \ 72 74 $(WebKit2)/UIProcess/Downloads \ … … 146 148 WebCookieManager \ 147 149 WebCookieManagerProxy \ 150 WebCredentialsMessenger \ 151 WebCredentialsMessengerProxy \ 148 152 WebFullScreenManager \ 149 153 WebFullScreenManagerProxy \ -
trunk/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp
r228442 r228444 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "WebCredentialsMessengerProxy.h" 27 28 28 29 #if ENABLE(WEB_AUTHN) 29 30 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ThreadSafeRefCounted.h> 32 #include <wtf/TypeCasts.h> 31 #include "WebCredentialsMessengerMessages.h" 32 #include "WebCredentialsMessengerProxyMessages.h" 33 #include "WebPageProxy.h" 34 #include "WebProcessProxy.h" 33 35 34 namespace Web Core{36 namespace WebKit { 35 37 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 37 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 38 WebCredentialsMessengerProxy::WebCredentialsMessengerProxy(WebPageProxy& webPageProxy) 39 : m_webPageProxy(webPageProxy) 40 { 41 m_webPageProxy.process().addMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID(), *this); 42 } 42 43 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 44 WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy() 45 { 46 m_webPageProxy.process().removeMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID()); 47 } 45 48 46 virtual Type type() const = 0; 49 void WebCredentialsMessengerProxy::makeCredential(uint64_t) 50 { 51 } 47 52 48 ArrayBuffer* clientDataJSON() const; 53 void WebCredentialsMessengerProxy::getAssertion(uint64_t) 54 { 55 } 49 56 50 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 52 }; 53 54 } // namespace WebCore 55 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \ 57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \ 58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \ 59 SPECIALIZE_TYPE_TRAITS_END() 57 } // namespace WebKit 60 58 61 59 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h
r228442 r228444 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ThreadSafeRefCounted.h> 32 #include <wtf/TypeCasts.h> 30 #include "MessageReceiver.h" 33 31 34 namespace Web Core{32 namespace WebKit { 35 33 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 34 class WebPageProxy; 35 36 class WebCredentialsMessengerProxy : private IPC::MessageReceiver { 37 37 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 42 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 45 46 virtual Type type() const = 0; 47 48 ArrayBuffer* clientDataJSON() const; 38 explicit WebCredentialsMessengerProxy(WebPageProxy&); 39 ~WebCredentialsMessengerProxy(); 49 40 50 41 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 42 // IPC::MessageReceiver. 43 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; 44 45 // Receivers. 46 void makeCredential(uint64_t messageId); 47 void getAssertion(uint64_t messageId); 48 49 WebPageProxy& m_webPageProxy; 52 50 }; 53 51 54 } // namespace WebCore 55 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \ 57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \ 58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \ 59 SPECIALIZE_TYPE_TRAITS_END() 52 } // namespace WebKit 60 53 61 54 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r228194 r228444 196 196 #endif 197 197 198 #if ENABLE(WEB_AUTHN) 199 #include "WebCredentialsMessengerProxy.h" 200 #endif 201 198 202 // This controls what strategy we use for mouse wheel coalescing. 199 203 #define MERGE_WHEEL_EVENTS 1 … … 409 413 #endif 410 414 415 #if ENABLE(WEB_AUTHN) 416 m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this); 417 #endif 418 411 419 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this); 412 420 … … 660 668 #if ENABLE(APPLE_PAY) 661 669 m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this); 670 #endif 671 672 #if ENABLE(WEB_AUTHN) 673 m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this); 662 674 #endif 663 675 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r227984 r228444 218 218 class WebNavigationState; 219 219 class VideoFullscreenManagerProxy; 220 class WebCredentialsMessengerProxy; 220 221 class WebKeyboardEvent; 221 222 class WebURLSchemeHandler; … … 1787 1788 #endif 1788 1789 1790 #if ENABLE(WEB_AUTHN) 1791 std::unique_ptr<WebCredentialsMessengerProxy> m_credentialsMessenger; 1792 #endif 1793 1789 1794 CallbackMap m_callbacks; 1790 1795 HashSet<CallbackID> m_loadDependentStringCallbackIDs; -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r228393 r228444 1210 1210 53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; }; 1211 1211 53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; }; 1212 5760828E2029895E00116678 /* WebCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760828C2029854200116678 /* WebCredentialsMessenger.cpp */; }; 1213 57608298202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */; }; 1214 5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */; }; 1215 5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */; }; 1216 5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */; }; 1217 5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */; }; 1212 1218 5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; }; 1213 1219 5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; }; … … 3631 3637 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkDataTaskBlob.h; path = NetworkProcess/NetworkDataTaskBlob.h; sourceTree = "<group>"; }; 3632 3638 53DEA3651DDE422E00E82648 /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = json.hpp; path = NetworkProcess/capture/json.hpp; sourceTree = "<group>"; }; 3639 5760828B2029854200116678 /* WebCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessenger.h; sourceTree = "<group>"; }; 3640 5760828C2029854200116678 /* WebCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessenger.cpp; sourceTree = "<group>"; }; 3641 5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessenger.messages.in; sourceTree = "<group>"; }; 3642 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerMessages.h; sourceTree = "<group>"; }; 3643 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerMessageReceiver.cpp; sourceTree = "<group>"; }; 3644 57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxy.h; sourceTree = "<group>"; }; 3645 57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxy.cpp; sourceTree = "<group>"; }; 3646 57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessengerProxy.messages.in; sourceTree = "<group>"; }; 3647 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxyMessageReceiver.cpp; sourceTree = "<group>"; }; 3648 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxyMessages.h; sourceTree = "<group>"; }; 3633 3649 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; }; 3634 3650 5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; }; … … 6683 6699 sourceTree = "<group>"; 6684 6700 }; 6701 5760828A202984C900116678 /* CredentialManagement */ = { 6702 isa = PBXGroup; 6703 children = ( 6704 5760828C2029854200116678 /* WebCredentialsMessenger.cpp */, 6705 5760828B2029854200116678 /* WebCredentialsMessenger.h */, 6706 5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */, 6707 ); 6708 path = CredentialManagement; 6709 sourceTree = "<group>"; 6710 }; 6711 57608294202BD84900116678 /* CredentialManagement */ = { 6712 isa = PBXGroup; 6713 children = ( 6714 57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */, 6715 57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */, 6716 57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */, 6717 ); 6718 path = CredentialManagement; 6719 sourceTree = "<group>"; 6720 }; 6685 6721 5C1426F11C23F81700D41183 /* Downloads */ = { 6686 6722 isa = PBXGroup; … … 6942 6978 7C6E70F818B2D47E00F24E2E /* cocoa */, 6943 6979 3309344B1315B93A0097A7BC /* Cookies */, 6980 5760828A202984C900116678 /* CredentialManagement */, 6944 6981 512A9754180DF9270039A149 /* Databases */, 6945 6982 BCACC43B16B24C5D00B6E092 /* EntryPoint */, … … 7099 7136 9955A6E81C79809000EB6A93 /* Automation */, 7100 7137 1ABC3DF21899E415004F0626 /* Cocoa */, 7138 57608294202BD84900116678 /* CredentialManagement */, 7101 7139 1AB7D4C71288AA9A00CFD08C /* Downloads */, 7102 7140 515BE17B1D54EF5A00DD7C68 /* Gamepad */, … … 8246 8284 330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */, 8247 8285 330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */, 8286 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */, 8287 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */, 8288 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */, 8289 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */, 8248 8290 CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */, 8249 8291 CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */, … … 9116 9158 BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */, 9117 9159 512F589B12A8838800629530 /* WebCredential.h in Headers */, 9160 5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */, 9161 5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */, 9118 9162 1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */, 9119 9163 CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */, … … 10802 10846 BCE23263122C6CF300D5C35A /* WebCoreArgumentCodersMac.mm in Sources */, 10803 10847 512F589A12A8838800629530 /* WebCredential.cpp in Sources */, 10848 5760828E2029895E00116678 /* WebCredentialsMessenger.cpp in Sources */, 10849 5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */, 10850 57608298202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp in Sources */, 10851 5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */, 10804 10852 1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */, 10805 10853 CD19A26D1A13E82A008D650E /* WebDiagnosticLoggingClient.cpp in Sources */, -
trunk/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp
r228442 r228444 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "WebCredentialsMessenger.h" 27 28 28 29 #if ENABLE(WEB_AUTHN) 29 30 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ThreadSafeRefCounted.h> 32 #include <wtf/TypeCasts.h> 31 #include "WebCredentialsMessengerMessages.h" 32 #include "WebCredentialsMessengerProxyMessages.h" 33 #include "WebPage.h" 34 #include "WebProcess.h" 33 35 34 namespace Web Core{36 namespace WebKit { 35 37 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 37 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 38 WebCredentialsMessenger::WebCredentialsMessenger(WebPage& webPage) 39 : m_webPage(webPage) 40 { 41 WebProcess::singleton().addMessageReceiver(Messages::WebCredentialsMessenger::messageReceiverName(), m_webPage.pageID(), *this); 42 } 42 43 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 44 WebCredentialsMessenger::~WebCredentialsMessenger() 45 { 46 WebProcess::singleton().removeMessageReceiver(*this); 47 } 45 48 46 virtual Type type() const = 0; 49 void WebCredentialsMessenger::makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::CreationCompletionHandler&&) 50 { 51 } 47 52 48 ArrayBuffer* clientDataJSON() const; 53 void WebCredentialsMessenger::getAssertion(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) 54 { 55 } 49 56 50 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 52 } ;57 void WebCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&) 58 { 59 } 53 60 54 } // namespace WebCore 61 void WebCredentialsMessenger::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) 62 { 63 } 55 64 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \ 57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \ 58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \ 59 SPECIALIZE_TYPE_TRAITS_END() 65 } // namespace WebKit 60 66 61 67 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h
r228442 r228444 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include <JavaScriptCore/ArrayBuffer.h> 31 #include <wtf/ThreadSafeRefCounted.h> 32 #include <wtf/TypeCasts.h> 30 #include "MessageReceiver.h" 31 #include <WebCore/CredentialsMessenger.h> 33 32 34 namespace Web Core{33 namespace WebKit { 35 34 36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> { 35 class WebPage; 36 37 class WebCredentialsMessenger final : public WebCore::CredentialsMessenger, private IPC::MessageReceiver { 37 38 public: 38 enum class Type { 39 Assertion, 40 Attestation 41 }; 42 43 explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&); 44 virtual ~AuthenticatorResponse() = default; 45 46 virtual Type type() const = 0; 47 48 ArrayBuffer* clientDataJSON() const; 39 explicit WebCredentialsMessenger(WebPage&); 40 ~WebCredentialsMessenger(); 49 41 50 42 private: 51 RefPtr<ArrayBuffer> m_clientDataJSON; 43 // WebCore::CredentialsMessenger 44 // sender 45 void makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::CreationCompletionHandler&&) final; 46 void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final; 47 48 // receiver 49 void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&) final; 50 void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) final; 51 52 // IPC::MessageReceiver. 53 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; 54 55 WebPage& m_webPage; 52 56 }; 53 57 54 } // namespace WebCore 55 56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \ 57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \ 58 static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \ 59 SPECIALIZE_TYPE_TRAITS_END() 58 } // namespace WebKit 60 59 61 60 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r228351 r228444 261 261 #endif 262 262 263 #if ENABLE(WEB_AUTHN) 264 #include "WebCredentialsMessenger.h" 265 #include <WebCore/AuthenticatorManager.h> 266 #endif 267 263 268 using namespace JSC; 264 269 using namespace WebCore; … … 371 376 , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy } 372 377 , m_cpuLimit(parameters.cpuLimit) 378 #if ENABLE(WEB_AUTHN) 379 , m_credentialsMessenger(std::make_unique<WebCredentialsMessenger>(*this)) 380 #endif 373 381 { 374 382 ASSERT(m_pageID); … … 579 587 enableEnumeratingAllNetworkInterfaces(); 580 588 #endif 589 #endif 590 591 #if ENABLE(WEB_AUTHN) 592 WebCore::AuthenticatorManager::singleton().setMessenger(*m_credentialsMessenger); 581 593 #endif 582 594 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r227984 r228444 212 212 class WebWheelEvent; 213 213 class WebTouchEvent; 214 class WebCredentialsMessenger; 214 215 class RemoteLayerTreeTransaction; 215 216 … … 1687 1688 HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap; 1688 1689 #endif 1690 1691 #if ENABLE(WEB_AUTHN) 1692 std::unique_ptr<WebCredentialsMessenger> m_credentialsMessenger; 1693 #endif 1694 1689 1695 }; 1690 1696
Note: See TracChangeset
for help on using the changeset viewer.