Changeset 286746 in webkit


Ignore:
Timestamp:
Dec 8, 2021, 3:49:16 PM (4 years ago)
Author:
J Pascoe
Message:

[WebAuthn] Consider support for the displayName for FIDO authenticator
https://bugs.webkit.org/show_bug.cgi?id=233389
rdar://84938707

Reviewed by Brent Fulgham.

Source/WebKit:

Start storing the displayName field with the platform authenticator
and add them to the getAllLocalAuthenticatorCredentials SPI.

The displayName is part of the WebAuthn level 2 spec:
https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialuserentity-displayname

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

(getAllLocalAuthenticatorCredentialsImpl):

  • UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:

(WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):

Tools:

Add test for new field stored with platform authenticator: displayName

  • TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r286709 r286746  
     12021-12-08  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] Consider support for the displayName for FIDO authenticator
     4        https://bugs.webkit.org/show_bug.cgi?id=233389
     5        rdar://84938707
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Start storing the displayName field with the platform authenticator
     10        and add them to the getAllLocalAuthenticatorCredentials SPI.
     11
     12        The displayName is part of the WebAuthn level 2 spec:
     13        https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialuserentity-displayname
     14
     15        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
     16        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
     17        (getAllLocalAuthenticatorCredentialsImpl):
     18        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     19        (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):
     20
    1212021-12-08  Truitt Savell  <tsavell@apple.com>
    222
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h

    r286078 r286746  
    8888
    8989WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialNameKey;
     90WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialDisplayNameKey;
    9091WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialIDKey;
    9192WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialRelyingPartyIDKey;
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm

    r285965 r286746  
    101101
    102102NSString * const _WKLocalAuthenticatorCredentialNameKey = @"_WKLocalAuthenticatorCredentialNameKey";
     103NSString * const _WKLocalAuthenticatorCredentialDisplayNameKey = @"_WKLocalAuthenticatorCredentialDisplayNameKey";
    103104NSString * const _WKLocalAuthenticatorCredentialIDKey = @"_WKLocalAuthenticatorCredentialIDKey";
    104105NSString * const _WKLocalAuthenticatorCredentialRelyingPartyIDKey = @"_WKLocalAuthenticatorCredentialRelyingPartyIDKey";
     
    266267        }
    267268        auto& username = it->second.getString();
    268 
    269         [result addObject:@{
    270             _WKLocalAuthenticatorCredentialNameKey: username,
    271             _WKLocalAuthenticatorCredentialIDKey: attributes[bridge_cast(kSecAttrApplicationLabel)],
    272             _WKLocalAuthenticatorCredentialRelyingPartyIDKey: attributes[bridge_cast(kSecAttrLabel)],
    273             _WKLocalAuthenticatorCredentialLastModificationDateKey: attributes[bridge_cast(kSecAttrModificationDate)],
    274             _WKLocalAuthenticatorCredentialCreationDateKey: attributes[bridge_cast(kSecAttrCreationDate)]
    275         }];
     269        auto credential = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys:
     270            username, _WKLocalAuthenticatorCredentialNameKey,
     271            attributes[bridge_cast(kSecAttrApplicationLabel)], _WKLocalAuthenticatorCredentialIDKey,
     272            attributes[bridge_cast(kSecAttrLabel)], _WKLocalAuthenticatorCredentialRelyingPartyIDKey,
     273            attributes[bridge_cast(kSecAttrModificationDate)], _WKLocalAuthenticatorCredentialLastModificationDateKey,
     274            attributes[bridge_cast(kSecAttrCreationDate)], _WKLocalAuthenticatorCredentialCreationDateKey,
     275            nil
     276        ]);
     277
     278        it = responseMap.find(cbor::CBORValue(fido::kDisplayNameMapKey));
     279        if (it != responseMap.end() && it->second.isString())
     280            [credential setObject:it->second.getString() forKey:_WKLocalAuthenticatorCredentialDisplayNameKey];
     281
     282        [result addObject:credential.get()];
    276283    }
    277284
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r285698 r286746  
    348348    // kSecAttrLabel: RP ID
    349349    // kSecAttrApplicationLabel: Credential ID (auto-gen by Keychain)
    350     // kSecAttrApplicationTag: { "id": UserEntity.id, "name": UserEntity.name } (CBOR encoded)
     350    // kSecAttrApplicationTag: { "id": UserEntity.id, "name": UserEntity.name, "displayName": UserEntity.name} (CBOR encoded)
    351351    // Noted, the vale of kSecAttrApplicationLabel is automatically generated by the Keychain, which is a SHA-1 hash of
    352352    // the public key.
    353353    const auto& secAttrLabel = creationOptions.rp.id;
    354354
     355    // id, name, and displayName are required in PublicKeyCredentialUserEntity
     356    // https://www.w3.org/TR/webauthn-2/#dictdef-publickeycredentialuserentity
    355357    cbor::CBORValue::MapValue userEntityMap;
    356358    userEntityMap[cbor::CBORValue(fido::kEntityIdMapKey)] = cbor::CBORValue(creationOptions.user.id);
    357359    userEntityMap[cbor::CBORValue(fido::kEntityNameMapKey)] = cbor::CBORValue(creationOptions.user.name);
     360    userEntityMap[cbor::CBORValue(fido::kDisplayNameMapKey)] = cbor::CBORValue(creationOptions.user.displayName);
    358361    auto userEntity = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(userEntityMap)));
    359362    ASSERT(userEntity);
  • trunk/Tools/ChangeLog

    r286709 r286746  
     12021-12-08  J Pascoe  <j_pascoe@apple.com>
     2
     3        [WebAuthn] Consider support for the displayName for FIDO authenticator
     4        https://bugs.webkit.org/show_bug.cgi?id=233389
     5        rdar://84938707
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add test for new field stored with platform authenticator: displayName
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
     12        (TestWebKitAPI::TEST):
     13
    1142021-12-08  Truitt Savell  <tsavell@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

    r286078 r286746  
    21942194}
    21952195
     2196TEST(WebAuthenticationPanel, GetAllCredentialWithDisplayName)
     2197{
     2198    reset();
     2199
     2200    // {"id": h'00010203040506070809', "name": "John", "displayName": "Johnny"}
     2201    ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "example.com", "o2JpZEoAAQIDBAUGBwgJZG5hbWVkSm9obmtkaXNwbGF5TmFtZWZKb2hubnk="));
     2202
     2203    auto after = adoptNS([[NSDate alloc] init]);
     2204
     2205    auto *credentials = [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentialsWithAccessGroup:@"com.apple.TestWebKitAPI"];
     2206    EXPECT_NOT_NULL(credentials);
     2207    EXPECT_EQ([credentials count], 1lu);
     2208
     2209    EXPECT_NOT_NULL([credentials firstObject]);
     2210    EXPECT_WK_STREQ([credentials firstObject][_WKLocalAuthenticatorCredentialNameKey], "John");
     2211    EXPECT_WK_STREQ([credentials firstObject][_WKLocalAuthenticatorCredentialDisplayNameKey], "Johnny");
     2212
     2213    cleanUpKeychain("example.com");
     2214}
     2215
    21962216TEST(WebAuthenticationPanel, UpdateCredentialUsername)
    21972217{
Note: See TracChangeset for help on using the changeset viewer.