⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285864 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 8:47:40 AM (5 years ago)
Author:
J Pascoe
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.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285856 r285864  
     12021-11-16  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] WebKitTestRunner/TWAPI lacks an entitlement and bundle identifier to use required [ASCAgent performAuthorizationRequestsForContext]
     4        https://bugs.webkit.org/show_bug.cgi?id=232846
     5        rdar://problem/85170633
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Covered by existing tests.
     10
     11        Calling to ASC requires converting WebAuthenticationRequestData to ASCCredentialRequestContext and then making
     12        a call to _WKAuthenticatorAssertionResponse, while also requiring entitlements currently unavailable in OpenSource.
     13        This change avoids calling out to ASC in tests using mock / virtual authenticators to avoid this problem, the
     14        serialization to and from ASCAgent can be tested seperately.
     15
     16        * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
     17        Refactor creation of ASCCredentialRequestContext.
     18        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
     19        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
     20        (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
     21        Refactor use of ASC and add clarifying comment about flow.
     22
    1232021-11-16  Kimmo Kinnunen  <kkinnunen@apple.com>
    224
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm

    r285736 r285864  
    239239}
    240240
    241 void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
    242 {
    243     auto requestContext = configureRegistrationRequestContext(options);
    244     performRequest(requestContext, WTFMove(handler));
    245 }
    246 
    247 void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
    248 {
    249     auto requestContext = configurationAssertionRequestContext(options);
    250     performRequest(requestContext, WTFMove(handler));
     241RetainPtr<ASCCredentialRequestContext> WebAuthenticatorCoordinatorProxy::contextForRequest(WebAuthenticationRequestData&& requestData)
     242{
     243    RetainPtr<ASCCredentialRequestContext> result;
     244    WTF::switchOn(requestData.options, [&](const PublicKeyCredentialCreationOptions& options) {
     245        result = configureRegistrationRequestContext(options);
     246    }, [&](const PublicKeyCredentialRequestOptions& options) {
     247        result = configurationAssertionRequestContext(options);
     248    });
     249    return result;
    251250}
    252251
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp

    r284142 r285864  
    5656}
    5757
    58 #if !HAVE(UNIFIED_ASC_AUTH_UI)
    5958void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
    6059{
     
    6665    handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr }, WTFMove(handler));
    6766}
    68 #endif
    6967
    7068void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler)
    7169{
     70    auto& authenticatorManager = m_webPageProxy.websiteDataStore().authenticatorManager();
     71
     72#if HAVE(UNIFIED_ASC_AUTH_UI)
     73    if (!authenticatorManager.isMock() && !authenticatorManager.isVirtual()) {
     74        auto context = contextForRequest(WTFMove(data));
     75        // performRequest calls out to ASCAgent which will then call [_WKWebAuthenticationPanel makeCredential/getAssertionWithChallenge]
     76        // which calls authenticatorManager.handleRequest(..)
     77        performRequest(context, WTFMove(handler));
     78        return;
     79    }
     80#endif // HAVE(UNIFIED_ASC_AUTH_UI)
     81
    7282    auto callback = [handler = WTFMove(handler)] (std::variant<Ref<AuthenticatorResponse>, ExceptionData>&& result) mutable {
    7383        ASSERT(RunLoop::isMain());
     
    7888        });
    7989    };
    80     m_webPageProxy.websiteDataStore().authenticatorManager().handleRequest(WTFMove(data), WTFMove(callback));
     90    authenticatorManager.handleRequest(WTFMove(data), WTFMove(callback));
    8191}
    8292
     
    8696    handler(LocalService::isAvailable());
    8797}
    88 #endif
     98#endif // !HAVE(UNIFIED_ASC_AUTH_UI)
    8999
    90100} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h

    r284071 r285864  
    7878
    7979#if HAVE(UNIFIED_ASC_AUTH_UI)
     80    RetainPtr<ASCCredentialRequestContext> contextForRequest(WebAuthenticationRequestData&&);
    8081    void performRequest(RetainPtr<ASCCredentialRequestContext>, RequestCompletionHandler&&);
    8182    RetainPtr<ASCAuthorizationRemotePresenter> m_presenter;
Note: See TracChangeset for help on using the changeset viewer.