Title: [270730] trunk/Source
Revision
270730
Author
[email protected]
Date
2020-12-11 21:19:32 -0800 (Fri, 11 Dec 2020)

Log Message

[WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
https://bugs.webkit.org/show_bug.cgi?id=219710
<rdar://problem/72154800>

Reviewed by Brent Fulgham.

Source/WebCore:

Covered by manual tests.

* Modules/webauthn/AuthenticatorAssertionResponse.h:
(WebCore::AuthenticatorAssertionResponse::laContext const):
(WebCore::AuthenticatorAssertionResponse::setLAContext):

Source/WebKit:

This patch adopts the new UI for the platform authenticator getAssertion flow. It's more or less
the same as the security key one except an LAContext will be passed in from the UI. Now LocalAuthenticator
will just utilize the LAContext from the UI.

* UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h:
* UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm:
(WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator):
(WebKit::AuthenticatorPresenterCoordinator::~AuthenticatorPresenterCoordinator):
(WebKit::AuthenticatorPresenterCoordinator::selectAssertionResponse):
(WebKit::AuthenticatorPresenterCoordinator::didSelectAssertionResponse):
* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected):
* UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm:
(-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270729 => 270730)


--- trunk/Source/WebCore/ChangeLog	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebCore/ChangeLog	2020-12-12 05:19:32 UTC (rev 270730)
@@ -1,3 +1,17 @@
+2020-12-11  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
+        https://bugs.webkit.org/show_bug.cgi?id=219710
+        <rdar://problem/72154800>
+
+        Reviewed by Brent Fulgham.
+
+        Covered by manual tests.
+
+        * Modules/webauthn/AuthenticatorAssertionResponse.h:
+        (WebCore::AuthenticatorAssertionResponse::laContext const):
+        (WebCore::AuthenticatorAssertionResponse::setLAContext):
+
 2020-12-11  Megan Gardner  <[email protected]>
 
         Infrastructure to store and restore AppHighlights

Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h (270729 => 270730)


--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h	2020-12-12 05:19:32 UTC (rev 270730)
@@ -31,6 +31,8 @@
 #include <wtf/RetainPtr.h>
 #include <wtf/spi/cocoa/SecuritySPI.h>
 
+OBJC_CLASS LAContext;
+
 namespace WebCore {
 
 class AuthenticatorAssertionResponse : public AuthenticatorResponse {
@@ -47,6 +49,7 @@
     const String& displayName() const { return m_displayName; }
     size_t numberOfCredentials() const { return m_numberOfCredentials; }
     SecAccessControlRef accessControl() const { return m_accessControl.get(); }
+    LAContext * laContext() const { return m_laContext.get(); }
 
     WEBCORE_EXPORT void setAuthenticatorData(Vector<uint8_t>&&);
     void setSignature(Ref<ArrayBuffer>&& signature) { m_signature = WTFMove(signature); }
@@ -53,6 +56,7 @@
     void setName(const String& name) { m_name = name; }
     void setDisplayName(const String& displayName) { m_displayName = displayName; }
     void setNumberOfCredentials(size_t numberOfCredentials) { m_numberOfCredentials = numberOfCredentials; }
+    void setLAContext(LAContext *context) { m_laContext = context; }
 
 private:
     AuthenticatorAssertionResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, RefPtr<ArrayBuffer>&&);
@@ -69,6 +73,7 @@
     String m_displayName;
     size_t m_numberOfCredentials { 0 };
     RetainPtr<SecAccessControlRef> m_accessControl;
+    RetainPtr<LAContext> m_laContext;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit/ChangeLog (270729 => 270730)


--- trunk/Source/WebKit/ChangeLog	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebKit/ChangeLog	2020-12-12 05:19:32 UTC (rev 270730)
@@ -1,3 +1,26 @@
+2020-12-11  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
+        https://bugs.webkit.org/show_bug.cgi?id=219710
+        <rdar://problem/72154800>
+
+        Reviewed by Brent Fulgham.
+
+        This patch adopts the new UI for the platform authenticator getAssertion flow. It's more or less
+        the same as the security key one except an LAContext will be passed in from the UI. Now LocalAuthenticator
+        will just utilize the LAContext from the UI.
+
+        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h:
+        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm:
+        (WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator):
+        (WebKit::AuthenticatorPresenterCoordinator::~AuthenticatorPresenterCoordinator):
+        (WebKit::AuthenticatorPresenterCoordinator::selectAssertionResponse):
+        (WebKit::AuthenticatorPresenterCoordinator::didSelectAssertionResponse):
+        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+        (WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected):
+        * UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm:
+        (-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]):
+
 2020-12-11  John Wilander  <[email protected]>
 
         PCM: Change debugModeSecondsUntilSend from 60 seconds to 10 seconds

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h (270729 => 270730)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h	2020-12-12 05:19:32 UTC (rev 270730)
@@ -35,15 +35,12 @@
 #include <wtf/RetainPtr.h>
 #include <wtf/WeakPtr.h>
 
+OBJC_CLASS ASCAuthorizationPresentationContext;
 OBJC_CLASS ASCAuthorizationPresenter;
 OBJC_CLASS ASCLoginChoiceProtocol;
 OBJC_CLASS LAContext;
 OBJC_CLASS WKASCAuthorizationPresenterDelegate;
 
-namespace WebCore {
-class AuthenticatorAssertionResponse;
-}
-
 namespace WebKit {
 
 class AuthenticatorManager;
@@ -56,6 +53,7 @@
     using CredentialRequestHandler = Function<void()>;
 
     AuthenticatorPresenterCoordinator(const AuthenticatorManager&, const String& rpId, const TransportSet&, WebCore::ClientDataType);
+    ~AuthenticatorPresenterCoordinator();
 
     void updatePresenter(WebAuthenticationStatus);
     void requestPin(uint64_t retries, CompletionHandler<void(const String&)>&&);
@@ -66,10 +64,11 @@
     void setCredentialRequestHandler(CredentialRequestHandler&& handler) { m_credentialRequestHandler = WTFMove(handler); }
     void setLAContext(LAContext *);
 
-    void didSelectAssertionResponse(ASCLoginChoiceProtocol *);
+    void didSelectAssertionResponse(ASCLoginChoiceProtocol *, LAContext *);
 
 private:
     WeakPtr<AuthenticatorManager> m_manager;
+    RetainPtr<ASCAuthorizationPresentationContext> m_context;
     RetainPtr<ASCAuthorizationPresenter> m_presenter;
     RetainPtr<WKASCAuthorizationPresenterDelegate> m_presenterDelegate;
 

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm (270729 => 270730)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm	2020-12-12 05:19:32 UTC (rev 270730)
@@ -41,20 +41,20 @@
     : m_manager(makeWeakPtr(manager))
 {
 #if HAVE(ASC_AUTH_UI)
-    auto presentationContext = adoptNS([allocASCAuthorizationPresentationContextInstance() initWithRequestContext:nullptr appIdentifier:nullptr]);
+    m_context = adoptNS([allocASCAuthorizationPresentationContextInstance() initWithRequestContext:nullptr appIdentifier:nullptr]);
     if ([getASCAuthorizationPresentationContextClass() instancesRespondToSelector:@selector(setServiceName:)])
-        [presentationContext setServiceName:rpId];
+        [m_context setServiceName:rpId];
 
     switch (type) {
     case ClientDataType::Create:
         if (transports.contains(AuthenticatorTransport::Internal))
-            [presentationContext addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
+            [m_context addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
         if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc))
-            [presentationContext addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
+            [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
         break;
     case ClientDataType::Get:
         if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc))
-            [presentationContext addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initAssertionPlaceholderChoice]).get()];
+            [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initAssertionPlaceholderChoice]).get()];
         break;
     default:
         ASSERT_NOT_REACHED();
@@ -76,10 +76,18 @@
                 manager->cancel();
         });
     });
-    [m_presenter presentAuthorizationWithContext:presentationContext.get() completionHandler:completionHandler.get()];
+    [m_presenter presentAuthorizationWithContext:m_context.get() completionHandler:completionHandler.get()];
 #endif // HAVE(ASC_AUTH_UI)
 }
 
+AuthenticatorPresenterCoordinator::~AuthenticatorPresenterCoordinator()
+{
+    if (m_laContextHandler)
+        m_laContextHandler(nullptr);
+    if (m_responseHandler)
+        m_responseHandler(nullptr);
+}
+
 void AuthenticatorPresenterCoordinator::updatePresenter(WebAuthenticationStatus)
 {
     // FIXME(219713): Adopt new UI for the update flow.
@@ -114,7 +122,25 @@
         [m_presenter updateInterfaceWithLoginChoices:loginChoices.get()];
         return;
     }
-    // FIXME(219710): Adopt new UI for the Platform Authenticator getAssertion flow.
+
+    if (source == WebAuthenticationSource::Local) {
+        auto loginChoices = adoptNS([[NSMutableArray alloc] init]);
+
+        for (auto& response : responses) {
+            RetainPtr<NSData> userHandle;
+            if (response->userHandle())
+                userHandle = adoptNS([[NSData alloc] initWithBytes:response->userHandle()->data() length:response->userHandle()->byteLength()]);
+
+            auto loginChoice = adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initWithName:response->name() displayName:response->displayName() userHandle:userHandle.get()]);
+            [loginChoices addObject:loginChoice.get()];
+
+            m_credentials.add((ASCLoginChoiceProtocol *)loginChoice.get(), WTFMove(response));
+        }
+
+        [loginChoices addObjectsFromArray:[m_context loginChoices]]; // Adds the security key option if exists.
+        [m_presenter updateInterfaceWithLoginChoices:loginChoices.get()];
+        return;
+    }
 #endif // HAVE(ASC_AUTH_UI)
 }
 
@@ -147,12 +173,15 @@
     m_laContext = context;
 }
 
-void AuthenticatorPresenterCoordinator::didSelectAssertionResponse(ASCLoginChoiceProtocol *loginChoice)
+void AuthenticatorPresenterCoordinator::didSelectAssertionResponse(ASCLoginChoiceProtocol *loginChoice, LAContext *context)
 {
     auto response = m_credentials.take(loginChoice);
     if (!response)
         return;
 
+    if (context)
+        response->setLAContext(context);
+
     m_responseHandler(response.get());
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (270729 => 270730)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2020-12-12 05:19:32 UTC (rev 270730)
@@ -531,6 +531,24 @@
     ASSERT(m_state == State::RequestReceived);
     m_state = State::ResponseSelected;
 
+    if (webAuthenticationModernEnabled()) {
+        auto accessControlRef = response->accessControl();
+        LAContext *context = response->laContext();
+        auto callback = [
+            weakThis = makeWeakPtr(*this),
+            response = WTFMove(response)
+        ] (LocalConnection::UserVerification verification) mutable {
+            ASSERT(RunLoop::isMain());
+            if (!weakThis)
+                return;
+
+            weakThis->continueGetAssertionAfterUserVerification(WTFMove(response), verification, response->laContext());
+        };
+
+        m_connection->verifyUser(accessControlRef, context, WTFMove(callback));
+        return;
+    }
+
     auto& requestOptions = WTF::get<PublicKeyCredentialRequestOptions>(requestData().options);
 
     auto accessControlRef = response->accessControl();

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm (270729 => 270730)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm	2020-12-12 03:19:41 UTC (rev 270729)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm	2020-12-12 05:19:32 UTC (rev 270730)
@@ -64,12 +64,20 @@
 
             return;
         }
+
+        if (![(ASCPlatformPublicKeyCredentialLoginChoice *)loginChoice isRegistrationRequest]) {
+            [self dispatchCoordinatorCallback:[loginChoice, context = retainPtr(context)] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable {
+                coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice, context.get());
+            }];
+
+            return;
+        }
     }
 
     if ([loginChoice isKindOfClass:WebKit::getASCSecurityKeyPublicKeyCredentialLoginChoiceClass()]) {
         if ([(ASCSecurityKeyPublicKeyCredentialLoginChoice *)loginChoice loginChoiceKind] == ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion) {
             [self dispatchCoordinatorCallback:[loginChoice] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable {
-                coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice);
+                coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice, nil);
             }];
 
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to