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

Changeset 285763 in webkit


Ignore:
Timestamp:
Nov 12, 2021, 4:55:20 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

_WKWebAuthenticationPanel should expose a way to encode CTAP commands
https://bugs.webkit.org/show_bug.cgi?id=232977
<rdar://85279329>

Patch by Garrett Davidson <davidson.garrettm@gmail.com> on 2021-11-12
Reviewed by David Kilzer.

Expose the existing CTAP command encoding through _WKWebAuthenticationPanel.

Covered by existing tests.

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

(coreUserVerificationAvailability):
(+[_WKWebAuthenticationPanel getClientDataJSONForAuthenticationType:challenge:origin:])
(+[_WKWebAuthenticationPanel encodeMakeCredentialCommandWithClientDataJSON:options:userVerificationAvailability:]):
(+[_WKWebAuthenticationPanel encodeGetAssertionCommandWithClientDataJSON:options:userVerificationAvailability:]):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285748 r285763  
     12021-11-12  Garrett Davidson  <davidson.garrettm@gmail.com>
     2
     3        _WKWebAuthenticationPanel should expose a way to encode CTAP commands
     4        https://bugs.webkit.org/show_bug.cgi?id=232977
     5        <rdar://85279329>
     6
     7        Reviewed by David Kilzer.
     8
     9        Expose the existing CTAP command encoding through _WKWebAuthenticationPanel.
     10
     11        Covered by existing tests.
     12
     13        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
     14        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
     15        (coreUserVerificationAvailability):
     16        (+[_WKWebAuthenticationPanel getClientDataJSONForAuthenticationType:challenge:origin:])
     17        (+[_WKWebAuthenticationPanel encodeMakeCredentialCommandWithClientDataJSON:options:userVerificationAvailability:]):
     18        (+[_WKWebAuthenticationPanel encodeGetAssertionCommandWithClientDataJSON:options:userVerificationAvailability:]):
     19
    1202021-11-12  Per Arne Vollan <pvollan@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h

    r285056 r285763  
    8181} WK_API_AVAILABLE(macos(11.0), ios(14.0));
    8282
     83typedef NS_ENUM(NSInteger, _WKWebAuthenticationUserVerificationAvailability) {
     84    _WKWebAuthenticationUserVerificationAvailabilitySupportedAndConfigured,
     85    _WKWebAuthenticationUserVerificationAvailabilitySupportedButNotConfigured,
     86    _WKWebAuthenticationUserVerificationAvailabilityNotSupported,
     87} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     88
    8389WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialNameKey;
    8490WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialIDKey;
     
    113119+ (BOOL)isUserVerifyingPlatformAuthenticatorAvailable WK_API_AVAILABLE(macos(12.0), ios(15.0));
    114120
     121+ (NSData *)getClientDataJSONForAuthenticationType:(_WKWebAuthenticationType)type challenge:(NSData *)challenge origin:(NSString *)origin WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     122+ (NSData *)encodeMakeCredentialCommandWithClientDataJSON:(NSData *)clientDataJSON options:(_WKPublicKeyCredentialCreationOptions *)options userVerificationAvailability:(_WKWebAuthenticationUserVerificationAvailability)userVerificationAvailability WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     123+ (NSData *)encodeGetAssertionCommandWithClientDataJSON:(NSData *)clientDataJSON options:(_WKPublicKeyCredentialRequestOptions *)options userVerificationAvailability:(_WKWebAuthenticationUserVerificationAvailability)userVerificationAvailability WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     124
    115125- (instancetype)init;
    116126
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm

    r285698 r285763  
    4949#import <WebCore/CBORReader.h>
    5050#import <WebCore/CBORWriter.h>
     51#import <WebCore/DeviceRequestConverter.h>
    5152#import <WebCore/FidoConstants.h>
    5253#import <WebCore/MockWebAuthenticationConfiguration.h>
     
    195196}
    196197
     198static fido::AuthenticatorSupportedOptions::UserVerificationAvailability coreUserVerificationAvailability(_WKWebAuthenticationUserVerificationAvailability wkAvailability)
     199{
     200    switch (wkAvailability) {
     201    case _WKWebAuthenticationUserVerificationAvailabilitySupportedAndConfigured:
     202        return fido::AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedAndConfigured;
     203    case _WKWebAuthenticationUserVerificationAvailabilitySupportedButNotConfigured:
     204        return fido::AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured;
     205    case _WKWebAuthenticationUserVerificationAvailabilityNotSupported:
     206        return fido::AuthenticatorSupportedOptions::UserVerificationAvailability::kNotSupported;
     207    }
     208
     209    ASSERT_NOT_REACHED();
     210    return fido::AuthenticatorSupportedOptions::UserVerificationAvailability::kNotSupported;
     211}
     212
    197213- (_WKWebAuthenticationType)type
    198214{
     
    624640}
    625641
     642+ (NSData *)getClientDataJSONForAuthenticationType:(_WKWebAuthenticationType)type challenge:(NSData *)challenge origin:(NSString *)origin
     643{
     644    RetainPtr<NSData> clientDataJSON;
     645
     646#if ENABLE(WEB_AUTHN)
     647    clientDataJSON = produceClientDataJson(type, challenge, origin);
     648#endif
     649
     650    return clientDataJSON.autorelease();
     651}
     652
     653+ (NSData *)encodeMakeCredentialCommandWithClientDataJSON:(NSData *)clientDataJSON options:(_WKPublicKeyCredentialCreationOptions *)options userVerificationAvailability:(_WKWebAuthenticationUserVerificationAvailability)userVerificationAvailability
     654{
     655    RetainPtr<NSData> encodedCommand;
     656#if ENABLE(WEB_AUTHN)
     657    auto hash = produceClientDataJsonHash(clientDataJSON);
     658
     659    auto encodedVector = fido::encodeMakeCredenitalRequestAsCBOR(hash, [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], coreUserVerificationAvailability(userVerificationAvailability), std::nullopt);
     660    encodedCommand = adoptNS([[NSData alloc] initWithBytes:encodedVector.data() length:encodedVector.size()]);
     661#endif
     662
     663    return encodedCommand.autorelease();
     664}
     665
     666+ (NSData *)encodeGetAssertionCommandWithClientDataJSON:(NSData *)clientDataJSON options:(_WKPublicKeyCredentialRequestOptions *)options userVerificationAvailability:(_WKWebAuthenticationUserVerificationAvailability)userVerificationAvailability
     667{
     668    RetainPtr<NSData> encodedCommand;
     669#if ENABLE(WEB_AUTHN)
     670    auto hash = produceClientDataJsonHash(clientDataJSON);
     671
     672    auto encodedVector = fido::encodeGetAssertionRequestAsCBOR(hash, [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], coreUserVerificationAvailability(userVerificationAvailability), std::nullopt);
     673    encodedCommand = adoptNS([[NSData alloc] initWithBytes:encodedVector.data() length:encodedVector.size()]);
     674#endif
     675
     676    return encodedCommand.autorelease();
     677}
     678
    626679- (void)setMockConfiguration:(NSDictionary *)configuration
    627680{
Note: See TracChangeset for help on using the changeset viewer.