Title: [291882] trunk
Revision
291882
Author
[email protected]
Date
2022-03-25 13:16:29 -0700 (Fri, 25 Mar 2022)

Log Message

[WebAuthn] Maintain last modification time separate from last used time for platform credentials
https://bugs.webkit.org/show_bug.cgi?id=238293
rdar://90655676

Reviewed by Brent Fulgham.

This patch splits a key returned from [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentials...],
_WKLocalAuthenticatorCredentialLastModificationDateKey, which previously signified the last time a
credential was modified or used in an assertion, to just the last time the credential was modified.

A new key, _WKLocalAuthenticatorCredentialLastUsedDateKey represents the old definition, the last
time a key was used or modified.

Source/WebCore:

* Modules/webauthn/WebAuthenticationConstants.h:

Source/WebKit:

* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
(getAllLocalAuthenticatorCredentialsImpl):
(+[_WKWebAuthenticationPanel setUsernameForLocalCredentialWithGroupAndID:credential:username:]):
* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):

Tools:

Updated API test to verify differences between _WKLocalAuthenticatorCredentialLastModificationDateKey
and _WKLocalAuthenticatorCredentialLastModificationDateKey.

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291881 => 291882)


--- trunk/Source/WebCore/ChangeLog	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebCore/ChangeLog	2022-03-25 20:16:29 UTC (rev 291882)
@@ -1,3 +1,20 @@
+2022-03-25  J Pascoe  <[email protected]>
+
+        [WebAuthn] Maintain last modification time separate from last used time for platform credentials
+        https://bugs.webkit.org/show_bug.cgi?id=238293
+        rdar://90655676
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits a key returned from [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentials...],
+        _WKLocalAuthenticatorCredentialLastModificationDateKey, which previously signified the last time a
+        credential was modified or used in an assertion, to just the last time the credential was modified.
+
+        A new key, _WKLocalAuthenticatorCredentialLastUsedDateKey represents the old definition, the last
+        time a key was used or modified.
+
+        * Modules/webauthn/WebAuthenticationConstants.h:
+
 2022-03-25  Zan Dobersek  <[email protected]>
 
         [TextureMapper] Implement GraphicsContextGLTextureMapperANGLE::prepareForDisplay()

Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (291881 => 291882)


--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h	2022-03-25 20:16:29 UTC (rev 291882)
@@ -83,6 +83,9 @@
 
 constexpr const char LocalAuthenticatorAccessGroup[] = "com.apple.webkit.webauthn";
 
+// User entity extension
+constexpr const char userEntityLastModifiedKey[] = "last_modified";
+
 // Credential serialization
 constexpr const char privateKeyKey[] = "priv";
 constexpr const char keyTypeKey[] = "key_type";

Modified: trunk/Source/WebKit/ChangeLog (291881 => 291882)


--- trunk/Source/WebKit/ChangeLog	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebKit/ChangeLog	2022-03-25 20:16:29 UTC (rev 291882)
@@ -1,3 +1,24 @@
+2022-03-25  J Pascoe  <[email protected]>
+        [WebAuthn] Maintain last modification time separate from last used time for platform credentials
+        https://bugs.webkit.org/show_bug.cgi?id=238293
+        rdar://90655676
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits a key returned from [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentials...],
+        _WKLocalAuthenticatorCredentialLastModificationDateKey, which previously signified the last time a
+        credential was modified or used in an assertion, to just the last time the credential was modified.
+
+        A new key, _WKLocalAuthenticatorCredentialLastUsedDateKey represents the old definition, the last
+        time a key was used or modified.
+
+        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
+        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
+        (getAllLocalAuthenticatorCredentialsImpl):
+        (+[_WKWebAuthenticationPanel setUsernameForLocalCredentialWithGroupAndID:credential:username:]):
+        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+        (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):
+
 2022-03-25  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] RemoteRenderingBackend::stopListeningForIPC() should not change the RemoteResourceCache on the main thread 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h (291881 => 291882)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h	2022-03-25 20:16:29 UTC (rev 291882)
@@ -101,6 +101,7 @@
 WK_EXTERN NSString * const _WKLocalAuthenticatorCredentialGroupKey;
 WK_EXTERN NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey;
 WK_EXTERN NSString * const _WKLocalAuthenticatorCredentialUserHandleKey;
+WK_EXTERN NSString * const _WKLocalAuthenticatorCredentialLastUsedDateKey;
 
 @protocol _WKWebAuthenticationPanelDelegate <NSObject>
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (291881 => 291882)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2022-03-25 20:16:29 UTC (rev 291882)
@@ -116,6 +116,7 @@
 NSString * const _WKLocalAuthenticatorCredentialGroupKey = @"_WKLocalAuthenticatorCredentialGroupKey";
 NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey = @"_WKLocalAuthenticatorCredentialSynchronizableKey";
 NSString * const _WKLocalAuthenticatorCredentialUserHandleKey = @"_WKLocalAuthenticatorCredentialUserHandleKey";
+NSString * const _WKLocalAuthenticatorCredentialLastUsedDateKey = @"_WKLocalAuthenticatorCredentialLastUsedDateKey";
 
 @implementation _WKWebAuthenticationPanel {
 #if ENABLE(WEB_AUTHN)
@@ -281,7 +282,7 @@
             username, _WKLocalAuthenticatorCredentialNameKey,
             attributes[bridge_cast(kSecAttrApplicationLabel)], _WKLocalAuthenticatorCredentialIDKey,
             attributes[bridge_cast(kSecAttrLabel)], _WKLocalAuthenticatorCredentialRelyingPartyIDKey,
-            attributes[bridge_cast(kSecAttrModificationDate)], _WKLocalAuthenticatorCredentialLastModificationDateKey,
+            attributes[bridge_cast(kSecAttrModificationDate)], _WKLocalAuthenticatorCredentialLastUsedDateKey,
             attributes[bridge_cast(kSecAttrCreationDate)], _WKLocalAuthenticatorCredentialCreationDateKey,
             nil
         ]);
@@ -292,6 +293,12 @@
         } else
             [credential setObject:[NSNull null] forKey:_WKLocalAuthenticatorCredentialUserHandleKey];
 
+        it = responseMap.find(cbor::CBORValue(WebCore::userEntityLastModifiedKey));
+        if (it != responseMap.end() && it->second.isUnsigned())
+            [credential setObject:[NSDate dateWithTimeIntervalSince1970:it->second.getUnsigned()] forKey:_WKLocalAuthenticatorCredentialLastModificationDateKey];
+        else
+            [credential setObject:attributes[bridge_cast(kSecAttrCreationDate)] forKey:_WKLocalAuthenticatorCredentialLastModificationDateKey];
+
         updateCredentialIfNecessary(credential.get(), attributes);
 
         it = responseMap.find(cbor::CBORValue(fido::kDisplayNameMapKey));
@@ -397,6 +404,7 @@
         ASSERT_NOT_REACHED();
         return;
     }
+    updatedUserMap[cbor::CBORValue(WebCore::userEntityLastModifiedKey)] = cbor::CBORValue((int64_t)WallTime::now().secondsSinceEpoch().value());
     auto updatedTag = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(updatedUserMap)));
 
     auto secAttrApplicationTag = adoptNS([[NSData alloc] initWithBytes:updatedTag->data() length:updatedTag->size()]);

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (291881 => 291882)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2022-03-25 20:16:29 UTC (rev 291882)
@@ -374,6 +374,7 @@
     userEntityMap[cbor::CBORValue(fido::kEntityIdMapKey)] = cbor::CBORValue(creationOptions.user.id);
     userEntityMap[cbor::CBORValue(fido::kEntityNameMapKey)] = cbor::CBORValue(creationOptions.user.name);
     userEntityMap[cbor::CBORValue(fido::kDisplayNameMapKey)] = cbor::CBORValue(creationOptions.user.displayName);
+    userEntityMap[cbor::CBORValue(userEntityLastModifiedKey)] = cbor::CBORValue((int64_t)WallTime::now().secondsSinceEpoch().value());
     auto userEntity = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(userEntityMap)));
     ASSERT(userEntity);
     auto secAttrApplicationTag = toNSData(*userEntity);

Modified: trunk/Tools/ChangeLog (291881 => 291882)


--- trunk/Tools/ChangeLog	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Tools/ChangeLog	2022-03-25 20:16:29 UTC (rev 291882)
@@ -1,3 +1,24 @@
+2022-03-25  J Pascoe  <[email protected]>
+
+        [WebAuthn] Maintain last modification time separate from last used time for platform credentials
+        https://bugs.webkit.org/show_bug.cgi?id=238293
+        rdar://90655676
+
+        Reviewed by Brent Fulgham.
+
+        This patch splits a key returned from [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentials...],
+        _WKLocalAuthenticatorCredentialLastModificationDateKey, which previously signified the last time a
+        credential was modified or used in an assertion, to just the last time the credential was modified.
+
+        A new key, _WKLocalAuthenticatorCredentialLastUsedDateKey represents the old definition, the last
+        time a key was used or modified.
+
+        Updated API test to verify differences between _WKLocalAuthenticatorCredentialLastModificationDateKey
+        and _WKLocalAuthenticatorCredentialLastModificationDateKey.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (TestWebKitAPI::TEST):
+
 2022-03-25  Jonathan Bedard  <[email protected]>
 
         [git-webkit] Handle no repository case

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (291881 => 291882)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2022-03-25 20:07:32 UTC (rev 291881)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2022-03-25 20:16:29 UTC (rev 291882)
@@ -2042,8 +2042,17 @@
 TEST(WebAuthenticationPanel, GetAssertionLA)
 {
     reset();
+    auto beforeTime = adoptNS([[NSDate alloc] init]);
 
     ASSERT_TRUE(addKeyToKeychain(testES256PrivateKeyBase64, "example.com", testUserEntityBundleBase64));
+    
+    auto *credentialsBefore = [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentialsWithAccessGroup:@"com.apple.TestWebKitAPI"];
+    EXPECT_NOT_NULL(credentialsBefore);
+    EXPECT_EQ([credentialsBefore count], 1lu);
+    EXPECT_NOT_NULL([credentialsBefore firstObject]);
+    EXPECT_EQ([[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialCreationDateKey]], 0);
+    EXPECT_EQ([[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialLastUsedDateKey]], 0);
+    EXPECT_GE([[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:beforeTime.get()], 0);
 
     uint8_t hash[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
     NSData *nsHash = [NSData dataWithBytes:hash length:sizeof(hash)];
@@ -2058,6 +2067,14 @@
 
     [panel getAssertionWithChallenge:nsHash origin:@"https://example.com" options:options.get() completionHandler:^(_WKAuthenticatorAssertionResponse *response, NSError *error) {
         webAuthenticationPanelRan = true;
+
+        auto *credentialsAfter = [_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentialsWithAccessGroup:@"com.apple.TestWebKitAPI"];
+        EXPECT_NOT_NULL(credentialsAfter);
+        EXPECT_EQ([credentialsAfter count], 1lu);
+        EXPECT_NOT_NULL([credentialsAfter firstObject]);
+        EXPECT_EQ([[credentialsAfter firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:[credentialsAfter firstObject][_WKLocalAuthenticatorCredentialCreationDateKey]], 0);
+        EXPECT_LE([[credentialsAfter firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:[credentialsAfter firstObject][_WKLocalAuthenticatorCredentialLastUsedDateKey]], 0);
+        EXPECT_GE([[credentialsBefore firstObject][_WKLocalAuthenticatorCredentialLastUsedDateKey] compare:beforeTime.get()], 0);
         cleanUpKeychain("example.com");
 
         EXPECT_NULL(error);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to