Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h (289816 => 289817)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h 2022-02-15 16:03:16 UTC (rev 289816)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h 2022-02-15 17:03:54 UTC (rev 289817)
@@ -92,6 +92,8 @@
WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialRelyingPartyIDKey;
WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialLastModificationDateKey;
WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialCreationDateKey;
+WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialGroupKey;
+WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey;
@protocol _WKWebAuthenticationPanelDelegate <NSObject>
@@ -114,10 +116,13 @@
+ (NSArray<NSDictionary *> *)getAllLocalAuthenticatorCredentials WK_API_AVAILABLE(macos(12.0), ios(15.0));
+ (void)deleteLocalAuthenticatorCredentialWithID:(NSData *)credentialID WK_API_AVAILABLE(macos(12.0), ios(15.0));
++ (void)deleteLocalAuthenticatorCredentialWithGroupAndID:(NSString * _Nullable)group credential:(NSData *)credentialID WK_API_AVAILABLE(macos(12.0), ios(15.0));
+ (void)clearAllLocalAuthenticatorCredentials WK_API_AVAILABLE(macos(12.0), ios(15.0));
+ (void)setUsernameForLocalCredentialWithID:(NSData *)credentialID username: (NSString *)username WK_API_AVAILABLE(macos(12.0), ios(15.0));
++ (void)setUsernameForLocalCredentialWithGroupAndID:(NSString * _Nullable)group credential:(NSData *)credentialID username: (NSString *)username WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (NSData *)exportLocalAuthenticatorCredentialWithID:(NSData *)credentialID error:(NSError **)error WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
++ (NSData *)exportLocalAuthenticatorCredentialWithGroupAndID:(NSString * _Nullable)group credential:(NSData *)credentialID error:(NSError **)error WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (NSData *)importLocalAuthenticatorCredential:(NSData *)credentialBlob error:(NSError **)error WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (NSData *)importLocalAuthenticatorWithAccessGroup:(NSString *)accessGroup credential:(NSData *)credentialBlob error:(NSError **)error WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (289816 => 289817)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2022-02-15 16:03:16 UTC (rev 289816)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2022-02-15 17:03:54 UTC (rev 289817)
@@ -71,6 +71,12 @@
static void updateQueryIfNecessary(NSMutableDictionary *)
{
}
+static inline void updateCredentialIfNecessary(NSMutableDictionary *credential, NSDictionary *attributes)
+{
+}
+static inline void updateQueryForGroupIfNecessary(NSMutableDictionary *dictionary, NSString *group)
+{
+}
#endif
static RetainPtr<NSData> produceClientDataJson(_WKWebAuthenticationType type, NSData *challenge, NSString *origin)
@@ -105,6 +111,8 @@
NSString * const _WKLocalAuthenticatorCredentialRelyingPartyIDKey = @"_WKLocalAuthenticatorCredentialRelyingPartyIDKey";
NSString * const _WKLocalAuthenticatorCredentialLastModificationDateKey = @"_WKLocalAuthenticatorCredentialLastModificationDateKey";
NSString * const _WKLocalAuthenticatorCredentialCreationDateKey = @"_WKLocalAuthenticatorCredentialCreationDateKey";
+NSString * const _WKLocalAuthenticatorCredentialGroupKey = @"_WKLocalAuthenticatorCredentialGroupKey";
+NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey = @"_WKLocalAuthenticatorCredentialSynchronizableKey";
@implementation _WKWebAuthenticationPanel {
#if ENABLE(WEB_AUTHN)
@@ -234,19 +242,18 @@
#if ENABLE(WEB_AUTHN)
static RetainPtr<NSArray> getAllLocalAuthenticatorCredentialsImpl(NSString *accessGroup)
{
- auto query = adoptNS([[NSMutableDictionary alloc] init]);
- [query setDictionary:@{
+ auto query = @{
(__bridge id)kSecClass: bridge_id_cast(kSecClassKey),
(__bridge id)kSecAttrKeyClass: bridge_id_cast(kSecAttrKeyClassPrivate),
(__bridge id)kSecAttrAccessGroup: accessGroup,
(__bridge id)kSecReturnAttributes: @YES,
(__bridge id)kSecMatchLimit: bridge_id_cast(kSecMatchLimitAll),
+ (__bridge id)kSecAttrSynchronizable: (id)kSecAttrSynchronizableAny,
(__bridge id)kSecUseDataProtectionKeychain: @YES
- }];
- updateQueryIfNecessary(query.get());
+ };
CFTypeRef attributesArrayRef = nullptr;
- OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query.get(), &attributesArrayRef);
+ OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
if (status && status != errSecItemNotFound)
return nullptr;
auto retainAttributesArray = adoptCF(attributesArrayRef);
@@ -274,6 +281,7 @@
attributes[bridge_cast(kSecAttrCreationDate)], _WKLocalAuthenticatorCredentialCreationDateKey,
nil
]);
+ updateCredentialIfNecessary(credential.get(), attributes);
it = responseMap.find(cbor::CBORValue(fido::kDisplayNameMapKey));
if (it != responseMap.end() && it->second.isString())
@@ -306,14 +314,20 @@
+ (void)deleteLocalAuthenticatorCredentialWithID:(NSData *)credentialID
{
+ [self deleteLocalAuthenticatorCredentialWithGroupAndID:nil credential:credentialID];
+}
+
++ (void)deleteLocalAuthenticatorCredentialWithGroupAndID:(NSString *)group credential:(NSData *)credentialID
+{
#if ENABLE(WEB_AUTHN)
auto deleteQuery = adoptNS([[NSMutableDictionary alloc] init]);
[deleteQuery setDictionary:@{
(__bridge id)kSecClass: bridge_id_cast(kSecClassKey),
(__bridge id)kSecAttrApplicationLabel: credentialID,
- (__bridge id)kSecUseDataProtectionKeychain: @YES
+ (__bridge id)kSecUseDataProtectionKeychain: @YES,
+ (__bridge id)kSecAttrSynchronizable: (id)kSecAttrSynchronizableAny
}];
- updateQueryIfNecessary(deleteQuery.get());
+ updateQueryForGroupIfNecessary(deleteQuery.get(), group);
SecItemDelete((__bridge CFDictionaryRef)deleteQuery.get());
#endif
@@ -328,6 +342,11 @@
+ (void)setUsernameForLocalCredentialWithID:(NSData *)credentialID username: (NSString *)username
{
+ [self setUsernameForLocalCredentialWithGroupAndID:nil credential:credentialID username:username];
+}
+
++ (void)setUsernameForLocalCredentialWithGroupAndID:(NSString *)group credential:(NSData *)credentialID username: (NSString *)username
+{
#if ENABLE(WEB_AUTHN)
auto query = adoptNS([[NSMutableDictionary alloc] init]);
[query setDictionary:@{
@@ -335,9 +354,10 @@
(__bridge id)kSecReturnAttributes: @YES,
(__bridge id)kSecAttrApplicationLabel: credentialID,
(__bridge id)kSecReturnPersistentRef : bridge_id_cast(kCFBooleanTrue),
+ (__bridge id)kSecAttrSynchronizable: (id)kSecAttrSynchronizableAny,
(__bridge id)kSecUseDataProtectionKeychain: @YES
}];
- updateQueryIfNecessary(query.get());
+ updateQueryForGroupIfNecessary(query.get(), group);
CFTypeRef attributesArrayRef = nullptr;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query.get(), &attributesArrayRef);
@@ -377,8 +397,9 @@
[query setDictionary:@{
(__bridge id)kSecValuePersistentRef: [attributes objectForKey:bridge_id_cast(kSecValuePersistentRef)],
(__bridge id)kSecClass: bridge_id_cast(kSecClassKey),
+ (__bridge id)kSecAttrSynchronizable: (id)kSecAttrSynchronizableAny,
}];
- updateQueryIfNecessary(query.get());
+ updateQueryForGroupIfNecessary(query.get(), group);
status = SecItemUpdate((__bridge CFDictionaryRef)query.get(), (__bridge CFDictionaryRef)updateParams);
if (status && status != errSecItemNotFound) {
@@ -526,6 +547,11 @@
+ (NSData *)exportLocalAuthenticatorCredentialWithID:(NSData *)credentialID error:(NSError **)error
{
+ return [self exportLocalAuthenticatorCredentialWithGroupAndID:nil credential:credentialID error:error];
+}
+
++ (NSData *)exportLocalAuthenticatorCredentialWithGroupAndID:(NSString *)group credential:(NSData *)credentialID error:(NSError **)error
+{
#if ENABLE(WEB_AUTHN)
auto query = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys:
(id)kSecClassKey, (id)kSecClass,
@@ -533,9 +559,11 @@
(id)kSecAttrKeyClassPrivate, (id)kSecAttrKeyClass,
@YES, (id)kSecReturnRef,
@YES, (id)kSecUseDataProtectionKeychain,
+ (id)kSecAttrSynchronizableAny, (id)kSecAttrSynchronizable,
nil
]);
- updateQueryIfNecessary(query.get());
+ updateQueryForGroupIfNecessary(query.get(), group);
+
CFTypeRef privateKeyRef = nullptr;
OSStatus status = SecItemCopyMatching(bridge_cast(query.get()), &privateKeyRef);
if (status && status != errSecItemNotFound) {