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

Changeset 276184 in webkit


Ignore:
Timestamp:
Apr 16, 2021, 5:14:03 PM (5 years ago)
Author:
jiewen_tan@apple.com
Message:

Pass credential name to the WebAuthn UI during registration
https://bugs.webkit.org/show_bug.cgi?id=224697
<rdar://75803352>

Reviewed by Brent Fulgham.

Source/WebKit:

Covered by new test contents within existing test files.

  • Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:

Paperwork for the new SPI.

  • UIProcess/API/APIWebAuthenticationPanel.cpp:

(API::WebAuthenticationPanel::create):
(API::WebAuthenticationPanel::WebAuthenticationPanel):

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

(-[_WKWebAuthenticationPanel userName]):
Adds a new userName property.

  • UIProcess/WebAuthentication/AuthenticatorManager.cpp:

(WebKit::WebCore::getUserName):
(WebKit::AuthenticatorManager::runPanel):
(WebKit::AuthenticatorManager::runPresenter):
Passes the userName to the UI.

  • UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h:
  • UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm:

Paperwork for the new SPI.

  • UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h:
  • UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm:

(WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator):
Passes the userName to the new SPI.

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r276182 r276184  
     12021-04-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Pass credential name to the WebAuthn UI during registration
     4        https://bugs.webkit.org/show_bug.cgi?id=224697
     5        <rdar://75803352>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Covered by new test contents within existing test files.
     10
     11        * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
     12        Paperwork for the new SPI.
     13
     14        * UIProcess/API/APIWebAuthenticationPanel.cpp:
     15        (API::WebAuthenticationPanel::create):
     16        (API::WebAuthenticationPanel::WebAuthenticationPanel):
     17        * UIProcess/API/APIWebAuthenticationPanel.h:
     18        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
     19        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
     20        (-[_WKWebAuthenticationPanel userName]):
     21        Adds a new userName property.
     22
     23        * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
     24        (WebKit::WebCore::getUserName):
     25        (WebKit::AuthenticatorManager::runPanel):
     26        (WebKit::AuthenticatorManager::runPresenter):
     27        Passes the userName to the UI.
     28
     29        * UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h:
     30        * UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm:
     31        Paperwork for the new SPI.
     32
     33        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h:
     34        * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm:
     35        (WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator):
     36        Passes the userName to the new SPI.
     37
    1382021-04-16  Cameron McCormack  <heycam@apple.com>
    239
  • trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h

    r272708 r276184  
    115115};
    116116
     117@interface ASCPublicKeyCredentialCreationOptions : NSObject <NSSecureCoding>
     118
     119@property (nonatomic, copy) NSData *challenge;
     120@property (nonatomic, copy) NSString *relyingPartyIdentifier;
     121@property (nonatomic, copy) NSString *userName;
     122@property (nonatomic, copy) NSData *userIdentifier;
     123@property (nonatomic, copy) NSString *userDisplayName;
     124@property (nonatomic, copy) NSArray<NSNumber *> *supportedAlgorithmIdentifiers;
     125
     126@property (nonatomic) BOOL shouldRequireResidentKey;
     127
     128@end
     129
    117130@interface ASCSecurityKeyPublicKeyCredentialLoginChoice : NSObject <ASCLoginChoiceProtocol>
    118131
    119 - (instancetype)initRegistrationChoice;
     132- (instancetype)initRegistrationChoiceWithOptions:(ASCPublicKeyCredentialCreationOptions *)options;
    120133- (instancetype)initWithName:(NSString *)name displayName:(NSString *)displayName userHandle:(NSData *)userHandle;
    121134- (instancetype)initAssertionPlaceholderChoice;
     
    133146@interface ASCPlatformPublicKeyCredentialLoginChoice : NSObject <ASCLoginChoiceProtocol>
    134147
    135 - (instancetype)initRegistrationChoice;
     148- (instancetype)initRegistrationChoiceWithOptions:(ASCPublicKeyCredentialCreationOptions *)options;
    136149- (instancetype)initWithName:(NSString *)name displayName:(NSString *)displayName userHandle:(NSData *)userHandle;
    137150
  • trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.cpp

    r272184 r276184  
    3838using namespace WebKit;
    3939
    40 Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type)
     40Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type, const WTF::String& userName)
    4141{
    42     return adoptRef(*new WebAuthenticationPanel(manager, rpId, transports, type));
     42    return adoptRef(*new WebAuthenticationPanel(manager, rpId, transports, type, userName));
    4343}
    4444
     
    5050}
    5151
    52 WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type)
     52WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type, const WTF::String& userName)
    5353    : m_client(makeUniqueRef<WebAuthenticationPanelClient>())
    5454    , m_weakManager(makeWeakPtr(manager))
    5555    , m_rpId(rpId)
    5656    , m_clientDataType(type)
     57    , m_userName(userName)
    5758{
    5859    m_transports = Vector<AuthenticatorTransport>();
  • trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.h

    r272184 r276184  
    7070    // FIXME: <rdar://problem/71509848> Remove the following deprecated methods.
    7171    using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
    72     static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
     72    static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType, const WTF::String& userName);
    7373    WTF::String rpId() const { return m_rpId; }
    7474    const Vector<WebCore::AuthenticatorTransport>& transports() const { return m_transports; }
    7575    WebCore::ClientDataType clientDataType() const { return m_clientDataType; }
     76    WTF::String userName() const { return m_userName; }
    7677
    7778private:
    7879    // FIXME: <rdar://problem/71509848> Remove the following deprecated method.
    79     WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType);
     80    WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType, const WTF::String& userName);
    8081
    8182    std::unique_ptr<WebKit::AuthenticatorManager> m_manager; // FIXME: <rdar://problem/71509848> Change to UniqueRef.
     
    8788    Vector<WebCore::AuthenticatorTransport> m_transports;
    8889    WebCore::ClientDataType m_clientDataType;
     90    WTF::String m_userName;
    8991};
    9092
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h

    r272826 r276184  
    121121@property (nonatomic, readonly, copy) NSSet *transports;
    122122@property (nonatomic, readonly) _WKWebAuthenticationType type;
     123@property (nonatomic, readonly, copy, nullable) NSString *userName;
    123124
    124125@end
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm

    r274894 r276184  
    181181    return wkWebAuthenticationType(_panel->clientDataType());
    182182}
     183
     184- (NSString *)userName
     185{
     186    return _panel->userName();
     187}
     188
    183189#else // ENABLE(WEB_AUTHN)
    184190- (id <_WKWebAuthenticationPanelDelegate>)delegate
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp

    r274894 r276184  
    154154}
    155155
     156static String getUserName(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options)
     157{
     158    if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options))
     159        return WTF::get<PublicKeyCredentialCreationOptions>(options).user.name;
     160    return emptyString();
     161}
     162
    156163} // namespace
    157164
     
    453460    }
    454461
    455     m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(options), transports, getClientDataType(options));
     462    m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(options), transports, getClientDataType(options), getUserName(options));
    456463    auto& panel = *m_pendingRequestData.panel;
    457464    page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, FrameInfoData { m_pendingRequestData.frameInfo }, [transports = WTFMove(transports), weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {
     
    481488
    482489    auto& options = m_pendingRequestData.options;
    483     m_presenter = makeUnique<AuthenticatorPresenterCoordinator>(*this, getRpId(options), transports, getClientDataType(options));
     490    m_presenter = makeUnique<AuthenticatorPresenterCoordinator>(*this, getRpId(options), transports, getClientDataType(options), getUserName(options));
    484491}
    485492
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h

    r275370 r276184  
    4040SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCSecurityKeyPublicKeyCredentialLoginChoice);
    4141SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAppleIDCredential);
     42SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPublicKeyCredentialCreationOptions);
    4243
    4344SOFT_LINK_CONSTANT_FOR_HEADER(WebKit, AuthenticationServicesCore, ASCAuthorizationErrorDomain, NSErrorDomain);
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm

    r275370 r276184  
    4040SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCSecurityKeyPublicKeyCredentialLoginChoice);
    4141SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAppleIDCredential);
     42SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPublicKeyCredentialCreationOptions);
    4243
    4344SOFT_LINK_CONSTANT_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationErrorDomain, NSErrorDomain);
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h

    r271872 r276184  
    5656    using CredentialRequestHandler = Function<void(ASCAppleIDCredential *, NSError *)>;
    5757
    58     AuthenticatorPresenterCoordinator(const AuthenticatorManager&, const String& rpId, const TransportSet&, WebCore::ClientDataType);
     58    AuthenticatorPresenterCoordinator(const AuthenticatorManager&, const String& rpId, const TransportSet&, WebCore::ClientDataType, const String& username);
    5959    ~AuthenticatorPresenterCoordinator();
    6060
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm

    r273276 r276184  
    3838using namespace WebCore;
    3939
    40 AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator(const AuthenticatorManager& manager, const String& rpId, const TransportSet& transports, ClientDataType type)
     40AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator(const AuthenticatorManager& manager, const String& rpId, const TransportSet& transports, ClientDataType type, const String& username)
    4141    : m_manager(makeWeakPtr(manager))
    4242{
     
    4747
    4848    switch (type) {
    49     case ClientDataType::Create:
     49    case ClientDataType::Create: {
     50        auto options = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]);
     51        [options setUserName:username];
     52
    5053        if (transports.contains(AuthenticatorTransport::Internal))
    51             [m_context addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
     54            [m_context addLoginChoice:adoptNS([allocASCPlatformPublicKeyCredentialLoginChoiceInstance() initRegistrationChoiceWithOptions:options.get()]).get()];
    5255        if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc))
    53             [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoice]).get()];
    54         break;
     56            [m_context addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initRegistrationChoiceWithOptions:options.get()]).get()];
     57        break;
     58    }
    5559    case ClientDataType::Get:
    5660        if ((transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc)) && !transports.contains(AuthenticatorTransport::Internal))
  • trunk/Tools/ChangeLog

    r276176 r276184  
     12021-04-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Pass credential name to the WebAuthn UI during registration
     4        https://bugs.webkit.org/show_bug.cgi?id=224697
     5        <rdar://75803352>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
     10        (TestWebKitAPI::TEST):
     11
    1122021-04-16  Kate Cheney  <katherine_cheney@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

    r274894 r276184  
    492492    // A bit of extra checks.
    493493    checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeCreate);
     494    EXPECT_WK_STREQ([delegate panel].userName, "John Appleseed");
    494495}
    495496
Note: See TracChangeset for help on using the changeset viewer.