[WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 07:59:20 +0000 (07:59 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 07:59:20 +0000 (07:59 +0000)
commit223ad97a94f0a3eee0073db91c67caab57da9bf7
tree60390ad56cb1c2379cc2facb060e48c774827f09
parent0d94b79cdfd08110df6aa93d41a7de92eb401b89
[WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
https://bugs.webkit.org/show_bug.cgi?id=189277
<rdar://problem/44115936>

Reviewed by Chris Dumez.

Source/WebCore:

This patch aims to polish AuthenticatorManager such that:
1) It is no longer a singleton. Instead, it will live with Page. It was a singleton simply because static
PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable() have to access it. However, this request
can be fulfilled by adding an attribute [CallWith=Document] to the IDL defination. Therefore, there is no
such need. Also, the singleton is illy implemented as it owns a single IPC proxy to UI Process which means
different web pages will talk to the same web page proxy. Anyway, making it live with Page should fix everything.
2) Since we are now planning to support external authenticators, the manager of all authenticators will then
have to live in UI Process which makes this AuthenticatorManager obsolete. Instead, rename it to AuthenticatorCoordinator.
3) Rename CredentialsMessenger to AuthenticatorCoordinatorClient to tight it to WebAuthN. Also, simplify the
message reply model as PublicKeyCredentialCreationOptions/PublicKeyCredentialRequestOptions =>
ExceptionData/PublicKeyCredentialData for makeCredential/getAssertion operations.
4) Restrict one request per time, i.e. makeCredential/getAssertion for a single page.
5) Unifying makeCredentialReply/getAssertionReply/exceptionReply into requestReply for IPC. Correspondingly,
unify callback and exceptionCallback into callback as well for LocalAuthenticator.
6) Enhance PublicKeyCredentialCreationOptions encoding/decoding with encoder.encodeFixedLengthData/decoder.decodeFixedLengthData.

Covered by existing tests.

* DerivedSources.make:
* Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::get):
(WebCore::CredentialsContainer::isCreate):
* Modules/credentialmanagement/CredentialsContainer.h:
* Modules/credentialmanagement/CredentialsMessenger.cpp: Removed.
* Modules/credentialmanagement/CredentialsMessenger.h: Removed.
* Modules/webauthn/AuthenticatorAssertionResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorAssertionResponse.h:
(WebCore::AuthenticatorAssertionResponse::create):
(WebCore::AuthenticatorAssertionResponse::authenticatorData const):
(WebCore::AuthenticatorAssertionResponse::signature const):
(WebCore::AuthenticatorAssertionResponse::userHandle const):
(WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
* Modules/webauthn/AuthenticatorAttestationResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorAttestationResponse.h:
(WebCore::AuthenticatorAttestationResponse::create):
(WebCore::AuthenticatorAttestationResponse::attestationObject const):
(WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
* Modules/webauthn/AuthenticatorCoordinator.cpp: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp.
(WebCore::AuthenticatorCoordinatorInternal::produceClientDataJson):
(WebCore::AuthenticatorCoordinatorInternal::produceClientDataJsonHash):
(WebCore::AuthenticatorCoordinatorInternal::initTimeoutTimer):
(WebCore::AuthenticatorCoordinatorInternal::didTimeoutTimerFire):
(WebCore::AuthenticatorCoordinator::AuthenticatorCoordinator):
(WebCore::AuthenticatorCoordinator::setClient):
(WebCore::AuthenticatorCoordinator::create const):
(WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
(WebCore::AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable const):
* Modules/webauthn/AuthenticatorCoordinator.h: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.h.
* Modules/webauthn/AuthenticatorCoordinatorClient.cpp: Added.
(WebCore::AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient):
(WebCore::AuthenticatorCoordinatorClient::requestReply):
(WebCore::AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply):
(WebCore::AuthenticatorCoordinatorClient::setRequestCompletionHandler):
(WebCore::AuthenticatorCoordinatorClient::addQueryCompletionHandler):
* Modules/webauthn/AuthenticatorCoordinatorClient.h: Copied from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
* Modules/webauthn/AuthenticatorResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorResponse.h:
(WebCore::AuthenticatorResponse::AuthenticatorResponse):
(WebCore::AuthenticatorResponse::clientDataJSON const):
* Modules/webauthn/PublicKeyCredential.cpp:
(WebCore::PublicKeyCredential::create):
(WebCore::PublicKeyCredential::tryCreate):
(WebCore::PublicKeyCredential::PublicKeyCredential):
(WebCore::PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable):
* Modules/webauthn/PublicKeyCredential.h:
* Modules/webauthn/PublicKeyCredential.idl:
* Modules/webauthn/PublicKeyCredentialCreationOptions.h:
(WebCore::PublicKeyCredentialCreationOptions::encode const):
(WebCore::PublicKeyCredentialCreationOptions::decode):
* Modules/webauthn/PublicKeyCredentialData.h: Added.
(WebCore::PublicKeyCredentialData::encode const):
(WebCore::PublicKeyCredentialData::decode):
* Modules/webauthn/cocoa/LocalAuthenticator.h:
* Modules/webauthn/cocoa/LocalAuthenticator.mm:
(WebCore::LocalAuthenticator::makeCredential):
(WebCore::LocalAuthenticator::getAssertion):
* Modules/webvr/VRStageParameters.cpp:
Add a header file to prevent linkage error.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
* page/Page.h:
(WebCore::Page::authenticatorCoordinator const):
* page/PageConfiguration.cpp:
* page/PageConfiguration.h:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::mockAuthenticatorCoordinator const):
(WebCore::Internals::mockCredentialsMessenger const): Deleted.
* testing/Internals.h:
* testing/Internals.idl:
* testing/MockAuthenticatorCoordinator.cpp: Added.
(WebCore::MockAuthenticatorCoordinator::setCreationReturnBundle):
(WebCore::MockAuthenticatorCoordinator::setAssertionReturnBundle):
(WebCore::MockAuthenticatorCoordinator::makeCredential):
(WebCore::MockAuthenticatorCoordinator::getAssertion):
(WebCore::MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
* testing/MockAuthenticatorCoordinator.h: Renamed from Source/WebCore/testing/MockCredentialsMessenger.h.
* testing/MockAuthenticatorCoordinator.idl: Renamed from Source/WebCore/testing/MockCredentialsMessenger.idl.
* testing/MockCredentialsMessenger.cpp: Removed.

Source/WebKit:

* DerivedSources.make:
* SourcesCocoa.txt:
* UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Removed.
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: Added.
(WebKit::WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy):
(WebKit::WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy):
(WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
(WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
(WebKit::WebAuthenticatorCoordinatorProxy::requestReply):
(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply):
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in.
* UIProcess/WebPageProxy.cpp:
(WebKit::m_resetRecentCrashCountTimer):
(WebKit::WebPageProxy::reattachToWebProcess):
* UIProcess/WebPageProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Removed.
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: Added.
(WebKit::WebAuthenticatorCoordinator::WebAuthenticatorCoordinator):
(WebKit::WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator):
(WebKit::WebAuthenticatorCoordinator::makeCredential):
(WebKit::WebAuthenticatorCoordinator::getAssertion):
(WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h.
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_cpuLimit):
(WebKit::m_credentialsMessenger): Deleted.
* WebProcess/WebPage/WebPage.h:

Tools:

* TestWebKitAPI/Tests/ios/LocalAuthenticator.mm:
(TestWebKitAPI::TEST):

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/public-key-is-user-verifying-platform-authenticator-available.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
63 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/public-key-is-user-verifying-platform-authenticator-available.html
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp [deleted file]
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h
Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp [moved from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp with 79% similarity]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h [moved from Source/WebCore/Modules/webauthn/AuthenticatorManager.h with 84% similarity]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorResponse.h
Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
Source/WebCore/Modules/webauthn/PublicKeyCredential.h
Source/WebCore/Modules/webauthn/PublicKeyCredential.idl
Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h
Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h
Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm
Source/WebCore/Modules/webvr/VRStageParameters.cpp
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/MockAuthenticatorCoordinator.cpp [new file with mode: 0644]
Source/WebCore/testing/MockAuthenticatorCoordinator.h [moved from Source/WebCore/testing/MockCredentialsMessenger.h with 68% similarity]
Source/WebCore/testing/MockAuthenticatorCoordinator.idl [moved from Source/WebCore/testing/MockCredentialsMessenger.idl with 97% similarity]
Source/WebCore/testing/MockCredentialsMessenger.cpp [deleted file]
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp [deleted file]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h [moved from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h with 70% similarity]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in [moved from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in with 83% similarity]
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp [deleted file]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h [moved from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h with 71% similarity]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in [moved from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in with 78% similarity]
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm