Title: [291988] trunk/Source/WebKit
Revision
291988
Author
[email protected]
Date
2022-03-28 13:58:18 -0700 (Mon, 28 Mar 2022)

Log Message

Adopt ASCPublicKeyCredentialCreationOptions's residentKeyPreference
https://bugs.webkit.org/show_bug.cgi?id=238387
rdar://problem/90845393

Reviewed by Brent Fulgham.

This patch passes along the residentKeyPreference to ASA, so it can  be passed
back via _WKAuthenticatorSelectionCriteria.residentKey.

* Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
* UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
(WebKit::toASCResidentKeyPreference):
(WebKit::configureRegistrationRequestContext):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (291987 => 291988)


--- trunk/Source/WebKit/ChangeLog	2022-03-28 20:43:02 UTC (rev 291987)
+++ trunk/Source/WebKit/ChangeLog	2022-03-28 20:58:18 UTC (rev 291988)
@@ -1,3 +1,19 @@
+2022-03-28  J Pascoe  <[email protected]>
+
+        Adopt ASCPublicKeyCredentialCreationOptions's residentKeyPreference 
+        https://bugs.webkit.org/show_bug.cgi?id=238387
+        rdar://problem/90845393
+
+        Reviewed by Brent Fulgham.
+
+        This patch passes along the residentKeyPreference to ASA, so it can  be passed
+        back via _WKAuthenticatorSelectionCriteria.residentKey.
+
+        * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
+        * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
+        (WebKit::toASCResidentKeyPreference):
+        (WebKit::configureRegistrationRequestContext):
+
 2022-03-28  Per Arne Vollan  <[email protected]>
 
         [iOS] Fix sandbox violation related to Network content filtering

Modified: trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (291987 => 291988)


--- trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h	2022-03-28 20:43:02 UTC (rev 291987)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h	2022-03-28 20:58:18 UTC (rev 291988)
@@ -183,6 +183,13 @@
     ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion = 1 << 5,
 };
 
+typedef NS_ENUM(NSInteger, ASPublicKeyCredentialResidentKeyPreference) {
+    ASPublicKeyCredentialResidentKeyPreferenceNotPresent,
+    ASPublicKeyCredentialResidentKeyPreferenceDiscouraged,
+    ASPublicKeyCredentialResidentKeyPreferencePreferred,
+    ASPublicKeyCredentialResidentKeyPreferenceRequired,
+};
+
 @interface ASCPublicKeyCredentialCreationOptions : NSObject <NSSecureCoding>
 
 @property (nonatomic, nullable, copy) NSData *challenge;
@@ -198,6 +205,7 @@
 @property (nonatomic, nullable, copy) NSNumber *timeout;
 
 @property (nonatomic) BOOL shouldRequireResidentKey;
+@property (nonatomic) ASPublicKeyCredentialResidentKeyPreference residentKeyPreference;
 @property (nonatomic, copy) NSArray<ASCPublicKeyCredentialDescriptor *> *excludedCredentials;
 
 @end

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (291987 => 291988)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	2022-03-28 20:43:02 UTC (rev 291987)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	2022-03-28 20:58:18 UTC (rev 291988)
@@ -182,6 +182,22 @@
     }
 }
 
+static inline ASPublicKeyCredentialResidentKeyPreference toASCResidentKeyPreference(std::optional<ResidentKeyRequirement> requirement, bool requireResidentKey)
+{
+    if (!requirement)
+        return requireResidentKey ? ASPublicKeyCredentialResidentKeyPreferenceRequired : ASPublicKeyCredentialResidentKeyPreferenceNotPresent;
+    switch (*requirement) {
+    case ResidentKeyRequirement::Discouraged:
+        return ASPublicKeyCredentialResidentKeyPreferenceDiscouraged;
+    case ResidentKeyRequirement::Preferred:
+        return ASPublicKeyCredentialResidentKeyPreferencePreferred;
+    case ResidentKeyRequirement::Required:
+        return ASPublicKeyCredentialResidentKeyPreferenceRequired;
+    }
+    ASSERT_NOT_REACHED();
+    return ASPublicKeyCredentialResidentKeyPreferenceNotPresent;
+}
+
 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options, const Vector<uint8_t>& hash, std::optional<WebCore::GlobalFrameIdentifier> globalFrameID)
 {
     ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration | ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration;
@@ -188,6 +204,7 @@
 
     RetainPtr<NSString> userVerification;
     bool shouldRequireResidentKey = false;
+    std::optional<ResidentKeyRequirement> residentKeyRequirement;
     std::optional<PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria> authenticatorSelection = options.authenticatorSelection;
     if (authenticatorSelection) {
         std::optional<AuthenticatorAttachment> attachment = authenticatorSelection->authenticatorAttachment;
@@ -199,6 +216,7 @@
         userVerification = toNSString(authenticatorSelection->userVerification);
 
         shouldRequireResidentKey = authenticatorSelection->requireResidentKey;
+        residentKeyRequirement = authenticatorSelection->residentKey;
     }
 
     auto requestContext = adoptNS([allocASCCredentialRequestContextInstance() initWithRequestTypes:requestTypes]);
@@ -216,7 +234,10 @@
     [credentialCreationOptions setUserIdentifier:WebCore::toNSData(options.user.id).get()];
     [credentialCreationOptions setUserDisplayName:options.user.displayName];
     [credentialCreationOptions setUserVerificationPreference:userVerification.get()];
-    [credentialCreationOptions setShouldRequireResidentKey:shouldRequireResidentKey];
+    if ([credentialCreationOptions respondsToSelector:@selector(setResidentKeyPreference:)])
+        [credentialCreationOptions setResidentKeyPreference:toASCResidentKeyPreference(residentKeyRequirement, shouldRequireResidentKey)];
+    else
+        [credentialCreationOptions setShouldRequireResidentKey:shouldRequireResidentKey];
     [credentialCreationOptions setAttestationPreference:toNSString(options.attestation).get()];
 
     RetainPtr<NSMutableArray<NSNumber *>> supportedAlgorithmIdentifiers = adoptNS([[NSMutableArray alloc] initWithCapacity:options.pubKeyCredParams.size()]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to