[WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Feb 2018 19:02:50 +0000 (19:02 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Feb 2018 19:02:50 +0000 (19:02 +0000)
commit80c52818b96e81ae766764dfc6391ffd77b56820
treebe8fdd309e5ca7448f65853db982e6071e9013cd
parent3d3b9f3f6a2ecad433576c2bdf83f920b0f1046d
[WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
https://bugs.webkit.org/show_bug.cgi?id=181946
<rdar://problem/37258262>

Reviewed by Chris Dumez.

Source/WebCore:

This patch changes the original async model from a work queue to IPC between WebProcess
and UIProcess. Since all authenticator operations must be handled in the UIProcess due
to sandboxing, this message passing IPC async model then surpasses the original multi
threading model. To cooperate that, a CredentialsMessenger class is then created and
all task dispatching code is moved thre.

As an improvement over existing code, static functions from PublicKeyCredential are
moved to AuthenticatorManager. AuthenticatorManager is made as a singleton such that
when static functions are called, they could reach the CredentialsMessenger to interact
with UIProccess. CredentialsMessenger and AuthenticatorManager are separated so later
on when other Credential types are created, they can reuse the same IPC messenger.

What's more, a mock CredentialsMessenger is then created to mock behaviors of UIProcess
for testing purpose.

Covered by existing tests.

* DerivedSources.make:
* Modules/credentialmanagement/BasicCredential.h:
* Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::CredentialsContainer):
(WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors):
(WebCore::CredentialsContainer::get):
(WebCore::CredentialsContainer::isCreate):
(WebCore::CredentialsContainer::PendingPromise::PendingPromise): Deleted.
(WebCore::CredentialsContainer::dispatchTask): Deleted.
* Modules/credentialmanagement/CredentialsContainer.h:
(WebCore::CredentialsContainer::PendingPromise::create): Deleted.
* Modules/credentialmanagement/CredentialsMessenger.cpp: Added.
(WebCore::CredentialsMessenger::exceptionReply):
(WebCore::CredentialsMessenger::addCreationCompletionHandler):
(WebCore::CredentialsMessenger::takeCreationCompletionHandler):
(WebCore::CredentialsMessenger::addRequestCompletionHandler):
(WebCore::CredentialsMessenger::takeRequestCompletionHandler):
(WebCore::CredentialsMessenger::addQueryCompletionHandler):
(WebCore::CredentialsMessenger::takeQueryCompletionHandler):
(WebCore::getIdFromAttestationObject):
* Modules/credentialmanagement/CredentialsMessenger.h: Added.
(WebCore::CreationReturnBundle::CreationReturnBundle):
(WebCore::AssertionReturnBundle::AssertionReturnBundle):
(WebCore::CredentialsMessenger::weakPtrFactory const):
* Modules/webauthn/Authenticator.cpp: Removed.
* Modules/webauthn/Authenticator.h: Removed.
* Modules/webauthn/AuthenticatorManager.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp.
(WebCore::AuthenticatorManagerInternal::produceClientDataJson):
(WebCore::AuthenticatorManagerInternal::produceClientDataJsonHash):
(WebCore::AuthenticatorManagerInternal::initTimer):
(WebCore::AuthenticatorManagerInternal::didTimerFire):
(WebCore::AuthenticatorManager::singleton):
(WebCore::AuthenticatorManager::setMessenger):
(WebCore::AuthenticatorManager::create const):
(WebCore::AuthenticatorManager::discoverFromExternalSource const):
* Modules/webauthn/AuthenticatorManager.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
* Modules/webauthn/AuthenticatorResponse.h:
* Modules/webauthn/PublicKeyCredential.cpp:
(WebCore::PublicKeyCredentialInternal::produceClientDataJson): Deleted.
(WebCore::PublicKeyCredentialInternal::produceClientDataJsonHash): Deleted.
(WebCore::PublicKeyCredentialInternal::getIdFromAttestationObject): Deleted.
(WebCore::PublicKeyCredential::collectFromCredentialStore): Deleted.
(WebCore::PublicKeyCredential::discoverFromExternalSource): Deleted.
(WebCore::PublicKeyCredential::store): Deleted.
(WebCore::PublicKeyCredential::create): Deleted.
(WebCore::PublicKeyCredential::rawId const): Deleted.
(WebCore::PublicKeyCredential::response const): Deleted.
* Modules/webauthn/PublicKeyCredential.h:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::mockCredentialsMessenger const):
* testing/Internals.h:
* testing/Internals.idl:
* testing/MockCredentialsMessenger.cpp: Added.
(WebCore::MockCredentialsMessenger::MockCredentialsMessenger):
(WebCore::MockCredentialsMessenger::~MockCredentialsMessenger):
(WebCore::MockCredentialsMessenger::setAttestationObject):
(WebCore::MockCredentialsMessenger::setAssertionReturnBundle):
(WebCore::MockCredentialsMessenger::makeCredential):
(WebCore::MockCredentialsMessenger::getAssertion):
(WebCore::MockCredentialsMessenger::makeCredentialReply):
(WebCore::MockCredentialsMessenger::getAssertionReply):
* testing/MockCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
* testing/MockCredentialsMessenger.idl: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.

Source/WebKit:

Dummy WebCredentialsMessenger and WebCredentialsMessengerProxy are crafted to establish
a message exchange channel between UIProcess and WebProcess.

* DerivedSources.make:
* UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
(WebKit::WebCredentialsMessengerProxy::WebCredentialsMessengerProxy):
(WebKit::WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy):
(WebKit::WebCredentialsMessengerProxy::makeCredential):
(WebKit::WebCredentialsMessengerProxy::getAssertion):
* UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
* UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in: Added.
* UIProcess/WebPageProxy.cpp:
(WebKit::m_configurationPreferenceValues):
(WebKit::WebPageProxy::reattachToWebProcess):
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
(WebKit::WebCredentialsMessenger::WebCredentialsMessenger):
(WebKit::WebCredentialsMessenger::~WebCredentialsMessenger):
(WebKit::WebCredentialsMessenger::makeCredential):
(WebKit::WebCredentialsMessenger::getAssertion):
(WebKit::WebCredentialsMessenger::makeCredentialReply):
(WebKit::WebCredentialsMessenger::getAssertionReply):
* WebProcess/CredentialManagement/WebCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
* WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in: Added.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_credentialsMessenger):
(WebKit::m_cpuLimit): Deleted.
* WebProcess/WebPage/WebPage.h:

LayoutTests:

* http/wpt/credential-management/credentialscontainer-store-basics.https.html:
* http/wpt/webauthn/idl.https.html:
* http/wpt/webauthn/public-key-credential-create-failure.https.html:
* http/wpt/webauthn/public-key-credential-create-success.https.html:
* http/wpt/webauthn/public-key-credential-get-failure.https.html:
* http/wpt/webauthn/public-key-credential-get-success.https.html:
* http/wpt/webauthn/resources/util.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html
LayoutTests/http/wpt/webauthn/idl.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html
LayoutTests/http/wpt/webauthn/resources/util.js
LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/credentialmanagement/BasicCredential.h
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp [new file with mode: 0644]
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/Authenticator.cpp [deleted file]
Source/WebCore/Modules/webauthn/Authenticator.h [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorManager.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorResponse.h
Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
Source/WebCore/Modules/webauthn/PublicKeyCredential.h
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/MockCredentialsMessenger.cpp [new file with mode: 0644]
Source/WebCore/testing/MockCredentialsMessenger.h [new file with mode: 0644]
Source/WebCore/testing/MockCredentialsMessenger.idl [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h [new file with mode: 0644]
Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in [new file with mode: 0644]
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h [new file with mode: 0644]
Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in [new file with mode: 0644]
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h