Title: [285864] trunk/Source/WebKit
Revision
285864
Author
[email protected]
Date
2021-11-16 08:47:40 -0800 (Tue, 16 Nov 2021)

Log Message

[WebAuthn] WebKitTestRunner/TWAPI lacks an entitlement and bundle identifier to use required [ASCAgent performAuthorizationRequestsForContext]
https://bugs.webkit.org/show_bug.cgi?id=232846
rdar://problem/85170633

Reviewed by Brent Fulgham.

Covered by existing tests.

Calling to ASC requires converting WebAuthenticationRequestData to ASCCredentialRequestContext and then making
a call to _WKAuthenticatorAssertionResponse, while also requiring entitlements currently unavailable in OpenSource.
This change avoids calling out to ASC in tests using mock / virtual authenticators to avoid this problem, the
serialization to and from ASCAgent can be tested seperately.

* UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
Refactor creation of ASCCredentialRequestContext.
(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
(WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
Refactor use of ASC and add clarifying comment about flow.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (285863 => 285864)


--- trunk/Source/WebKit/ChangeLog	2021-11-16 16:38:52 UTC (rev 285863)
+++ trunk/Source/WebKit/ChangeLog	2021-11-16 16:47:40 UTC (rev 285864)
@@ -1,3 +1,25 @@
+2021-11-16  J Pascoe  <[email protected]>
+
+        [WebAuthn] WebKitTestRunner/TWAPI lacks an entitlement and bundle identifier to use required [ASCAgent performAuthorizationRequestsForContext]
+        https://bugs.webkit.org/show_bug.cgi?id=232846
+        rdar://problem/85170633
+
+        Reviewed by Brent Fulgham.
+
+        Covered by existing tests.
+
+        Calling to ASC requires converting WebAuthenticationRequestData to ASCCredentialRequestContext and then making
+        a call to _WKAuthenticatorAssertionResponse, while also requiring entitlements currently unavailable in OpenSource.
+        This change avoids calling out to ASC in tests using mock / virtual authenticators to avoid this problem, the
+        serialization to and from ASCAgent can be tested seperately.
+
+        * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
+        Refactor creation of ASCCredentialRequestContext.
+        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
+        (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
+        Refactor use of ASC and add clarifying comment about flow.
+
 2021-11-16  Kimmo Kinnunen  <[email protected]>
 
         RemoteGraphicsContextGLCocoa::m_swapChain is unused

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (285863 => 285864)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	2021-11-16 16:38:52 UTC (rev 285863)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	2021-11-16 16:47:40 UTC (rev 285864)
@@ -238,18 +238,17 @@
     return requestContext;
 }
 
-void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
+RetainPtr<ASCCredentialRequestContext> WebAuthenticatorCoordinatorProxy::contextForRequest(WebAuthenticationRequestData&& requestData)
 {
-    auto requestContext = configureRegistrationRequestContext(options);
-    performRequest(requestContext, WTFMove(handler));
+    RetainPtr<ASCCredentialRequestContext> result;
+    WTF::switchOn(requestData.options, [&](const PublicKeyCredentialCreationOptions& options) {
+        result = configureRegistrationRequestContext(options);
+    }, [&](const PublicKeyCredentialRequestOptions& options) {
+        result = configurationAssertionRequestContext(options);
+    });
+    return result;
 }
 
-void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
-{
-    auto requestContext = configurationAssertionRequestContext(options);
-    performRequest(requestContext, WTFMove(handler));
-}
-
 void WebAuthenticatorCoordinatorProxy::performRequest(RetainPtr<ASCCredentialRequestContext> requestContext, RequestCompletionHandler&& handler)
 {
     auto proxy = adoptNS([allocASCAgentProxyInstance() init]);

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp (285863 => 285864)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2021-11-16 16:38:52 UTC (rev 285863)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2021-11-16 16:47:40 UTC (rev 285864)
@@ -55,7 +55,6 @@
     m_webPageProxy.process().removeMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.webPageID());
 }
 
-#if !HAVE(UNIFIED_ASC_AUTH_UI)
 void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
 {
     handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr }, WTFMove(handler));
@@ -65,10 +64,21 @@
 {
     handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr }, WTFMove(handler));
 }
-#endif
 
 void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler)
 {
+    auto& authenticatorManager = m_webPageProxy.websiteDataStore().authenticatorManager();
+
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+    if (!authenticatorManager.isMock() && !authenticatorManager.isVirtual()) {
+        auto context = contextForRequest(WTFMove(data));
+        // performRequest calls out to ASCAgent which will then call [_WKWebAuthenticationPanel makeCredential/getAssertionWithChallenge]
+        // which calls authenticatorManager.handleRequest(..)
+        performRequest(context, WTFMove(handler));
+        return;
+    }
+#endif // HAVE(UNIFIED_ASC_AUTH_UI)
+
     auto callback = [handler = WTFMove(handler)] (std::variant<Ref<AuthenticatorResponse>, ExceptionData>&& result) mutable {
         ASSERT(RunLoop::isMain());
         WTF::switchOn(result, [&](const Ref<AuthenticatorResponse>& response) {
@@ -77,7 +87,7 @@
             handler({ }, (AuthenticatorAttachment)0, exception);
         });
     };
-    m_webPageProxy.websiteDataStore().authenticatorManager().handleRequest(WTFMove(data), WTFMove(callback));
+    authenticatorManager.handleRequest(WTFMove(data), WTFMove(callback));
 }
 
 #if !HAVE(UNIFIED_ASC_AUTH_UI)
@@ -85,7 +95,7 @@
 {
     handler(LocalService::isAvailable());
 }
-#endif
+#endif // !HAVE(UNIFIED_ASC_AUTH_UI)
 
 } // namespace WebKit
 

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h (285863 => 285864)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2021-11-16 16:38:52 UTC (rev 285863)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2021-11-16 16:47:40 UTC (rev 285864)
@@ -77,6 +77,7 @@
     WebPageProxy& m_webPageProxy;
 
 #if HAVE(UNIFIED_ASC_AUTH_UI)
+    RetainPtr<ASCCredentialRequestContext> contextForRequest(WebAuthenticationRequestData&&);
     void performRequest(RetainPtr<ASCCredentialRequestContext>, RequestCompletionHandler&&);
     RetainPtr<ASCAuthorizationRemotePresenter> m_presenter;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to