Title: [290154] trunk
Revision
290154
Author
[email protected]
Date
2022-02-18 12:37:00 -0800 (Fri, 18 Feb 2022)

Log Message

[WebAuthn] Add credentialID to _WKWebAuthenticationAssertionResponse and userHandle in getAllLocalAuthenticatorCredentials
https://bugs.webkit.org/show_bug.cgi?id=236657
rdar://problem/88979279

Reviewed by Brent Fulgham.

Source/WebKit:

Modified API tests to verify new fields present and populated.

* UIProcess/API/APIWebAuthenticationAssertionResponse.cpp:
(API::WebAuthenticationAssertionResponse::credentialID const):
* UIProcess/API/APIWebAuthenticationAssertionResponse.h:
* UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.h:
* UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.mm:
(-[_WKWebAuthenticationAssertionResponse credentialID]):
* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
(getAllLocalAuthenticatorCredentialsImpl):

Tools:

Adjusted existing API tests, GetAllCredential and MultipleAccounts, to test for new fields
being returned and that they match the values expected. These values stem from testUserEntityBundleBase64
and testAssertionMessageLongBase64.

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(-[TestWebAuthenticationPanelDelegate panel:selectAssertionResponse:source:completionHandler:]):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (290153 => 290154)


--- trunk/Source/WebKit/ChangeLog	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/ChangeLog	2022-02-18 20:37:00 UTC (rev 290154)
@@ -1,3 +1,23 @@
+2022-02-18  J Pascoe  <[email protected]>
+
+        [WebAuthn] Add credentialID to _WKWebAuthenticationAssertionResponse and userHandle in getAllLocalAuthenticatorCredentials
+        https://bugs.webkit.org/show_bug.cgi?id=236657
+        rdar://problem/88979279
+
+        Reviewed by Brent Fulgham.
+
+        Modified API tests to verify new fields present and populated.
+
+        * UIProcess/API/APIWebAuthenticationAssertionResponse.cpp:
+        (API::WebAuthenticationAssertionResponse::credentialID const):
+        * UIProcess/API/APIWebAuthenticationAssertionResponse.h:
+        * UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.h:
+        * UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.mm:
+        (-[_WKWebAuthenticationAssertionResponse credentialID]):
+        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h:
+        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
+        (getAllLocalAuthenticatorCredentialsImpl):
+
 2022-02-18  Tim Horton  <[email protected]>
 
         Client-set minimum effective device width is not respected if AllowViewportShrinkToFitContent is enabled

Modified: trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.cpp (290153 => 290154)


--- trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.cpp	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.cpp	2022-02-18 20:37:00 UTC (rev 290154)
@@ -58,6 +58,18 @@
     return data;
 }
 
+RefPtr<Data> WebAuthenticationAssertionResponse::credentialID() const
+{
+    RefPtr<API::Data> data;
+    if (auto* rawId = m_response->rawId()) {
+        rawId->ref();
+        data = "" char*>(rawId->data()), rawId->byteLength(), [] (unsigned char*, const void* data) {
+            static_cast<ArrayBuffer*>(const_cast<void*>(data))->deref();
+        }, rawId);
+    }
+    return data;
+}
+
 } // namespace API
 
 #endif // ENABLE(WEB_AUTHN)

Modified: trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.h (290153 => 290154)


--- trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.h	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.h	2022-02-18 20:37:00 UTC (rev 290154)
@@ -44,6 +44,7 @@
     RefPtr<Data> userHandle() const;
     bool synchronizable() const { return m_response->synchronizable(); }
     const WTF::String& group() const { return m_response->group(); }
+    RefPtr<Data> credentialID() const;
 
     void setLAContext(LAContext *context) { m_response->setLAContext(context); }
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.h (290153 => 290154)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.h	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.h	2022-02-18 20:37:00 UTC (rev 290154)
@@ -38,6 +38,7 @@
 @property (nonatomic, readonly, copy) NSData *userHandle;
 @property (nonatomic, readonly) BOOL synchronizable;
 @property (nonatomic, readonly, copy) NSString *group;
+@property (nonatomic, readonly, copy) NSData *credentialID;
 
 - (void)setLAContext:(LAContext *)context WK_API_AVAILABLE(macos(12.0), ios(15.0));
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.mm (290153 => 290154)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.mm	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationAssertionResponse.mm	2022-02-18 20:37:00 UTC (rev 290154)
@@ -68,6 +68,11 @@
     return _response->group();
 }
 
+- (NSData *)credentialID
+{
+    return wrapper(_response->credentialID());
+}
+
 #endif // ENABLE(WEB_AUTHN)
 
 - (void)setLAContext:(LAContext *)context

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h	2022-02-18 20:37:00 UTC (rev 290154)
@@ -94,6 +94,7 @@
 WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialCreationDateKey;
 WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialGroupKey;
 WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey;
+WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialUserHandleKey;
 
 @protocol _WKWebAuthenticationPanelDelegate <NSObject>
 

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2022-02-18 20:37:00 UTC (rev 290154)
@@ -114,6 +114,7 @@
 NSString * const _WKLocalAuthenticatorCredentialCreationDateKey = @"_WKLocalAuthenticatorCredentialCreationDateKey";
 NSString * const _WKLocalAuthenticatorCredentialGroupKey = @"_WKLocalAuthenticatorCredentialGroupKey";
 NSString * const _WKLocalAuthenticatorCredentialSynchronizableKey = @"_WKLocalAuthenticatorCredentialSynchronizableKey";
+NSString * const _WKLocalAuthenticatorCredentialUserHandleKey = @"_WKLocalAuthenticatorCredentialUserHandleKey";
 
 @implementation _WKWebAuthenticationPanel {
 #if ENABLE(WEB_AUTHN)
@@ -274,6 +275,14 @@
             return nullptr;
         }
         auto& username = it->second.getString();
+
+        it = responseMap.find(cbor::CBORValue(fido::kEntityIdMapKey));
+        if (it == responseMap.end() || !it->second.isByteString()) {
+            ASSERT_NOT_REACHED();
+            return nullptr;
+        }
+        auto& userHandle = it->second.getByteString();
+
         auto credential = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys:
             username, _WKLocalAuthenticatorCredentialNameKey,
             attributes[bridge_cast(kSecAttrApplicationLabel)], _WKLocalAuthenticatorCredentialIDKey,
@@ -280,6 +289,7 @@
             attributes[bridge_cast(kSecAttrLabel)], _WKLocalAuthenticatorCredentialRelyingPartyIDKey,
             attributes[bridge_cast(kSecAttrModificationDate)], _WKLocalAuthenticatorCredentialLastModificationDateKey,
             attributes[bridge_cast(kSecAttrCreationDate)], _WKLocalAuthenticatorCredentialCreationDateKey,
+            adoptNS([[NSData alloc] initWithBytes:userHandle.data() length:userHandle.size()]).get(), _WKLocalAuthenticatorCredentialUserHandleKey,
             nil
         ]);
         updateCredentialIfNecessary(credential.get(), attributes);

Modified: trunk/Tools/ChangeLog (290153 => 290154)


--- trunk/Tools/ChangeLog	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Tools/ChangeLog	2022-02-18 20:37:00 UTC (rev 290154)
@@ -1,3 +1,19 @@
+2022-02-18  J Pascoe  <[email protected]>
+
+        [WebAuthn] Add credentialID to _WKWebAuthenticationAssertionResponse and userHandle in getAllLocalAuthenticatorCredentials
+        https://bugs.webkit.org/show_bug.cgi?id=236657
+        rdar://problem/88979279
+
+        Reviewed by Brent Fulgham.
+
+        Adjusted existing API tests, GetAllCredential and MultipleAccounts, to test for new fields
+        being returned and that they match the values expected. These values stem from testUserEntityBundleBase64
+        and testAssertionMessageLongBase64.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (-[TestWebAuthenticationPanelDelegate panel:selectAssertionResponse:source:completionHandler:]):
+        (TestWebKitAPI::TEST):
+
 2022-02-18  Brandon Stewart  <[email protected]>
 
         Generate compile_commands.json on macOS Builds

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (290153 => 290154)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2022-02-18 20:30:09 UTC (rev 290153)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2022-02-18 20:37:00 UTC (rev 290154)
@@ -180,6 +180,7 @@
     EXPECT_EQ(source, _WKWebAuthenticationSourceExternal);
     EXPECT_EQ(responses.count, 2ul);
     for (_WKWebAuthenticationAssertionResponse *response in responses) {
+        EXPECT_TRUE([[response.credentialID base64EncodedStringWithOptions:0] isEqual:@"KAitzuj+Tslzelf3/vZwIGtDQNgoKeFd5oEieYzhyzA65saf0tK2w/mooa7tQtGgDdwZIjOhjcuZ0pQ1ajoE4A=="] || !response.credentialID);
         EXPECT_TRUE([response.name isEqual:@"[email protected]"] || [response.name isEqual:@""]);
         EXPECT_TRUE([response.displayName isEqual:@"John P. Smith"] || [response.displayName isEqual:@""]);
         EXPECT_TRUE([[response.userHandle base64EncodedStringWithOptions:0] isEqual:@"MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII="] || !response.userHandle);
@@ -2174,6 +2175,7 @@
     EXPECT_NOT_NULL([credentials firstObject]);
     EXPECT_WK_STREQ([credentials firstObject][_WKLocalAuthenticatorCredentialNameKey], "John");
     EXPECT_WK_STREQ([[credentials firstObject][_WKLocalAuthenticatorCredentialIDKey] base64EncodedStringWithOptions:0], "SMSXHngF7hEOsElA73C3RY+8bR4=");
+    EXPECT_WK_STREQ([[credentials firstObject][_WKLocalAuthenticatorCredentialUserHandleKey] base64EncodedStringWithOptions:0], "AAECAwQFBgcICQ==");
     EXPECT_WK_STREQ([credentials firstObject][_WKLocalAuthenticatorCredentialRelyingPartyIDKey], "example.com");
 
     EXPECT_GE([[credentials firstObject][_WKLocalAuthenticatorCredentialLastModificationDateKey] compare:before.get()], 0);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to