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

Changeset 285965 in webkit


Ignore:
Timestamp:
Nov 17, 2021, 4:10:02 PM (5 years ago)
Author:
J Pascoe
Message:

[WebAuthn] Add SPI for makeCredential / getAssertion using clientDataHash
https://bugs.webkit.org/show_bug.cgi?id=233216
<rdar://problem/85476386>

Reviewed by Brent Fulgham.

In order to avoid needing to make and coordinate changes to ASC to support new fields or changes
within ClientDataJSON and to maintain a single source of truth, calls to ASC from WebKit
will contain a precomputed ClientDataHash. This change creates new SPIs that will be called
from ASC using the ClientDataHash.

  • UIProcess/API/Cocoa/_WKAuthenticatorResponse.h:
  • UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:

(-[_WKWebAuthenticationPanel makeCredentialWithClientDataHash:options:completionHandler:]):
(-[_WKWebAuthenticationPanel getAssertionWithClientDataHash:options:completionHandler:]):
New functions to take in ClientDataHash instead of the data needed to construct it.

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285959 r285965  
     12021-11-17  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] Add SPI for makeCredential / getAssertion using clientDataHash
     4        https://bugs.webkit.org/show_bug.cgi?id=233216
     5        <rdar://problem/85476386>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        In order to avoid needing to make and coordinate changes to ASC to support new fields or changes
     10        within ClientDataJSON and to maintain a single source of truth, calls to ASC from WebKit
     11        will contain a precomputed ClientDataHash. This change creates new SPIs that will be called
     12        from ASC using the ClientDataHash.
     13
     14        * UIProcess/API/Cocoa/_WKAuthenticatorResponse.h:
     15        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
     16        (-[_WKWebAuthenticationPanel makeCredentialWithClientDataHash:options:completionHandler:]):
     17        (-[_WKWebAuthenticationPanel getAssertionWithClientDataHash:options:completionHandler:]):
     18        New functions to take in ClientDataHash instead of the data needed to construct it.
     19
    1202021-11-17  Per Arne Vollan  <pvollan@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorResponse.h

    r279089 r285965  
    3939
    4040@property (nonatomic, readonly) _WKAuthenticatorAttachment attachment;
    41 @property (nonatomic, readonly) NSData *clientDataJSON;
     41@property (nullable, nonatomic, readonly) NSData *clientDataJSON;
    4242@property (nonatomic, readonly) NSData *rawId;
    4343@property (nullable, nonatomic, readonly, strong) _WKAuthenticationExtensionsClientOutputs *extensions;
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm

    r285763 r285965  
    581581}
    582582
     583- (void)makeCredentialWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler
     584{
     585#if ENABLE(WEB_AUTHN)
     586    auto callback = [handler = makeBlockPtr(handler)] (std::variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>&& result) mutable {
     587        WTF::switchOn(result, [&](const Ref<WebCore::AuthenticatorResponse>& response) {
     588            handler(wkAuthenticatorAttestationResponse(response->data(), nullptr, response->attachment()).get(), nil);
     589        }, [&](const WebCore::ExceptionData& exception) {
     590            handler(nil, [NSError errorWithDomain:WKErrorDomain code:exception.code userInfo:@{ NSLocalizedDescriptionKey: exception.message }]);
     591        });
     592    };
     593    _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr }, WTFMove(callback));
     594#endif
     595}
     596
    583597+ (WebCore::PublicKeyCredentialRequestOptions)convertToCoreRequestOptionsWithOptions:(_WKPublicKeyCredentialRequestOptions *)options
    584598{
     
    631645}
    632646
     647- (void)getAssertionWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler
     648{
     649#if ENABLE(WEB_AUTHN)
     650    auto callback = [handler = makeBlockPtr(handler)] (std::variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>&& result) mutable {
     651        WTF::switchOn(result, [&](const Ref<WebCore::AuthenticatorResponse>& response) {
     652            handler(wkAuthenticatorAssertionResponse(response->data(), nullptr, response->attachment()).get(), nil);
     653        }, [&](const WebCore::ExceptionData& exception) {
     654            handler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:nil]);
     655        });
     656    };
     657    _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr }, WTFMove(callback));
     658#endif
     659}
     660
    633661+ (BOOL)isUserVerifyingPlatformAuthenticatorAvailable
    634662{
Note: See TracChangeset for help on using the changeset viewer.