Changeset 270730 in webkit


Ignore:
Timestamp:
Dec 11, 2020 9:19:32 PM (3 years ago)
Author:
jiewen_tan@apple.com
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:]):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r270729 r270730  
     12020-12-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
     4        https://bugs.webkit.org/show_bug.cgi?id=219710
     5        <rdar://problem/72154800>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Covered by manual tests.
     10
     11        * Modules/webauthn/AuthenticatorAssertionResponse.h:
     12        (WebCore::AuthenticatorAssertionResponse::laContext const):
     13        (WebCore::AuthenticatorAssertionResponse::setLAContext):
     14
    1152020-12-11  Megan Gardner  <megan_gardner@apple.com>
    216
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h

    r258293 r270730  
    3232#include <wtf/spi/cocoa/SecuritySPI.h>
    3333
     34OBJC_CLASS LAContext;
     35
    3436namespace WebCore {
    3537
     
    4850    size_t numberOfCredentials() const { return m_numberOfCredentials; }
    4951    SecAccessControlRef accessControl() const { return m_accessControl.get(); }
     52    LAContext * laContext() const { return m_laContext.get(); }
    5053
    5154    WEBCORE_EXPORT void setAuthenticatorData(Vector<uint8_t>&&);
     
    5457    void setDisplayName(const String& displayName) { m_displayName = displayName; }
    5558    void setNumberOfCredentials(size_t numberOfCredentials) { m_numberOfCredentials = numberOfCredentials; }
     59    void setLAContext(LAContext *context) { m_laContext = context; }
    5660
    5761private:
     
    7074    size_t m_numberOfCredentials { 0 };
    7175    RetainPtr<SecAccessControlRef> m_accessControl;
     76    RetainPtr<LAContext> m_laContext;
    7277};
    7378
  • trunk/Source/WebKit/ChangeLog

    r270726 r270730  
     12020-12-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
     4        https://bugs.webkit.org/show_bug.cgi?id=219710
     5        <rdar://problem/72154800>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch adopts the new UI for the platform authenticator getAssertion flow. It's more or less
     10        the same as the security key one except an LAContext will be passed in from the UI. Now LocalAuthenticator
     11        will just utilize the LAContext from the UI.
     12
     13        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h:
     14        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm:
     15        (WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator):
     16        (WebKit::AuthenticatorPresenterCoordinator::~AuthenticatorPresenterCoordinator):
     17        (WebKit::AuthenticatorPresenterCoordinator::selectAssertionResponse):
     18        (WebKit::AuthenticatorPresenterCoordinator::didSelectAssertionResponse):
     19        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     20        (WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected):
     21        * UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm:
     22        (-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]):
     23
    1242020-12-11  John Wilander  <wilander@apple.com>
    225
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h

    r270724 r270730  
    3636#include <wtf/WeakPtr.h>
    3737
     38OBJC_CLASS ASCAuthorizationPresentationContext;
    3839OBJC_CLASS ASCAuthorizationPresenter;
    3940OBJC_CLASS ASCLoginChoiceProtocol;
    4041OBJC_CLASS LAContext;
    4142OBJC_CLASS WKASCAuthorizationPresenterDelegate;
    42 
    43 namespace WebCore {
    44 class AuthenticatorAssertionResponse;
    45 }
    4643
    4744namespace WebKit {
     
    5754
    5855    AuthenticatorPresenterCoordinator(const AuthenticatorManager&, const String& rpId, const TransportSet&, WebCore::ClientDataType);
     56    ~AuthenticatorPresenterCoordinator();
    5957
    6058    void updatePresenter(WebAuthenticationStatus);
     
    6765    void setLAContext(LAContext *);
    6866
    69     void didSelectAssertionResponse(ASCLoginChoiceProtocol *);
     67    void didSelectAssertionResponse(ASCLoginChoiceProtocol *, LAContext *);
    7068
    7169private:
    7270    WeakPtr<AuthenticatorManager> m_manager;
     71    RetainPtr<ASCAuthorizationPresentationContext> m_context;
    7372    RetainPtr<ASCAuthorizationPresenter> m_presenter;
    7473    RetainPtr<WKASCAuthorizationPresenterDelegate> m_presenterDelegate;
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm

    r270724 r270730  
    4242{
    4343#if HAVE(ASC_AUTH_UI)
    44     auto presentationContext = adoptNS([allocASCAuthorizationPresentationContextInstance() initWithRequestContext:nullptr appIdentifier:nullptr]);
     44    m_context = adoptNS([allocASCAuthorizationPresentationContextInstance() initWithRequestContext:nullptr appIdentifier:nullptr]);
    4545    if ([getASCAuthorizationPresentationContextClass() instancesRespondToSelector:@selector(setServiceName:)])
    46         [presentationContext setServiceName:rpId];
     46        [m_context setServiceName:rpId];
    4747
    4848    switch (type) {
    4949    case ClientDataType::Create:
    5050        if (transports.contains(AuthenticatorTransport::Internal))
    51             [presentationContext addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
     51            [m_context addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
    5252        if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc))
    53             [presentationContext addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
     53            [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
    5454        break;
    5555    case ClientDataType::Get:
    5656        if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc))
    57             [presentationContext addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initAssertionPlaceholderChoice]).get()];
     57            [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initAssertionPlaceholderChoice]).get()];
    5858        break;
    5959    default:
     
    7777        });
    7878    });
    79     [m_presenter presentAuthorizationWithContext:presentationContext.get() completionHandler:completionHandler.get()];
     79    [m_presenter presentAuthorizationWithContext:m_context.get() completionHandler:completionHandler.get()];
    8080#endif // HAVE(ASC_AUTH_UI)
     81}
     82
     83AuthenticatorPresenterCoordinator::~AuthenticatorPresenterCoordinator()
     84{
     85    if (m_laContextHandler)
     86        m_laContextHandler(nullptr);
     87    if (m_responseHandler)
     88        m_responseHandler(nullptr);
    8189}
    8290
     
    115123        return;
    116124    }
    117     // FIXME(219710): Adopt new UI for the Platform Authenticator getAssertion flow.
     125
     126    if (source == WebAuthenticationSource::Local) {
     127        auto loginChoices = adoptNS([[NSMutableArray alloc] init]);
     128
     129        for (auto& response : responses) {
     130            RetainPtr<NSData> userHandle;
     131            if (response->userHandle())
     132                userHandle = adoptNS([[NSData alloc] initWithBytes:response->userHandle()->data() length:response->userHandle()->byteLength()]);
     133
     134            auto loginChoice = adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initWithName:response->name() displayName:response->displayName() userHandle:userHandle.get()]);
     135            [loginChoices addObject:loginChoice.get()];
     136
     137            m_credentials.add((ASCLoginChoiceProtocol *)loginChoice.get(), WTFMove(response));
     138        }
     139
     140        [loginChoices addObjectsFromArray:[m_context loginChoices]]; // Adds the security key option if exists.
     141        [m_presenter updateInterfaceWithLoginChoices:loginChoices.get()];
     142        return;
     143    }
    118144#endif // HAVE(ASC_AUTH_UI)
    119145}
     
    148174}
    149175
    150 void AuthenticatorPresenterCoordinator::didSelectAssertionResponse(ASCLoginChoiceProtocol *loginChoice)
     176void AuthenticatorPresenterCoordinator::didSelectAssertionResponse(ASCLoginChoiceProtocol *loginChoice, LAContext *context)
    151177{
    152178    auto response = m_credentials.take(loginChoice);
    153179    if (!response)
    154180        return;
     181
     182    if (context)
     183        response->setLAContext(context);
    155184
    156185    m_responseHandler(response.get());
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r270694 r270730  
    532532    m_state = State::ResponseSelected;
    533533
     534    if (webAuthenticationModernEnabled()) {
     535        auto accessControlRef = response->accessControl();
     536        LAContext *context = response->laContext();
     537        auto callback = [
     538            weakThis = makeWeakPtr(*this),
     539            response = WTFMove(response)
     540        ] (LocalConnection::UserVerification verification) mutable {
     541            ASSERT(RunLoop::isMain());
     542            if (!weakThis)
     543                return;
     544
     545            weakThis->continueGetAssertionAfterUserVerification(WTFMove(response), verification, response->laContext());
     546        };
     547
     548        m_connection->verifyUser(accessControlRef, context, WTFMove(callback));
     549        return;
     550    }
     551
    534552    auto& requestOptions = WTF::get<PublicKeyCredentialRequestOptions>(requestData().options);
    535553
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm

    r270724 r270730  
    6565            return;
    6666        }
     67
     68        if (![(ASCPlatformPublicKeyCredentialLoginChoice *)loginChoice isRegistrationRequest]) {
     69            [self dispatchCoordinatorCallback:[loginChoice, context = retainPtr(context)] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable {
     70                coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice, context.get());
     71            }];
     72
     73            return;
     74        }
    6775    }
    6876
     
    7078        if ([(ASCSecurityKeyPublicKeyCredentialLoginChoice *)loginChoice loginChoiceKind] == ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion) {
    7179            [self dispatchCoordinatorCallback:[loginChoice] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable {
    72                 coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice);
     80                coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice, nil);
    7381            }];
    7482
Note: See TracChangeset for help on using the changeset viewer.