Changeset 291625 in webkit
- Timestamp:
- Mar 22, 2022 10:12:15 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (modified) (6 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r291624 r291625 1 2022-03-22 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Pass along timeout to ASA and ignore timeout for conditional mediation requests 4 https://bugs.webkit.org/show_bug.cgi?id=238147 5 rdar://90509464 6 7 Reviewed by Brent Fulgham. 8 9 Currently we don't pass the timeout from the rp into ASA, so the default timeout is always used. 10 This patch starts passing along the timeout to ASA, and creates a place for ASA to specify the 11 mediation of the request, so we can ignore the timeout for requests using conditional mediation. 12 13 Modified API test. 14 15 * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h: 16 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h: 17 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm: 18 (toWebCore): 19 (-[_WKWebAuthenticationPanel makeCredentialWithMediationRequirement:clientDataHash:options:completionHandler:]): 20 (-[_WKWebAuthenticationPanel makeCredentialWithClientDataHash:options:completionHandler:]): 21 (-[_WKWebAuthenticationPanel getAssertionWithMediationRequirement:clientDataHash:options:completionHandler:]): 22 (-[_WKWebAuthenticationPanel getAssertionWithClientDataHash:options:completionHandler:]): 23 * UIProcess/WebAuthentication/AuthenticatorManager.cpp: 24 (WebKit::AuthenticatorManager::respondReceived): 25 (WebKit::AuthenticatorManager::initTimeOutTimer): 26 * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: 27 (WebKit::configureRegistrationRequestContext): 28 (WebKit::configureAssertionOptions): 29 1 30 2022-03-22 J Pascoe <j_pascoe@apple.com> 2 31 -
trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h
r291177 r291625 165 165 @property (nonatomic, nullable, readonly, copy) NSString *userVerificationPreference; 166 166 @property (nonatomic, nullable, copy) ASCWebAuthenticationExtensionsClientInputs *extensions; 167 @property (nonatomic, nullable, copy) NSNumber *timeout; 167 168 168 169 @property (nonatomic, nullable, readonly, copy) NSArray<ASCPublicKeyCredentialDescriptor *> *allowedCredentials; … … 195 196 @property (nonatomic, nullable, copy) NSString *attestationPreference; 196 197 @property (nonatomic, nullable, copy) ASCWebAuthenticationExtensionsClientInputs *extensions; 198 @property (nonatomic, nullable, copy) NSNumber *timeout; 197 199 198 200 @property (nonatomic) BOOL shouldRequireResidentKey; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h
r290154 r291625 87 87 } WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 88 88 89 typedef NS_ENUM(NSInteger, _WKWebAuthenticationMediationRequirement) { 90 _WKWebAuthenticationMediationRequirementSilent, 91 _WKWebAuthenticationMediationRequirementOptional, 92 _WKWebAuthenticationMediationRequirementRequired, 93 _WKWebAuthenticationMediationRequirementConditional, 94 } WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 95 89 96 WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialNameKey; 90 97 WK_EXPORT extern NSString * const _WKLocalAuthenticatorCredentialDisplayNameKey; … … 142 149 - (void)makeCredentialWithChallenge:(NSData *)challenge origin:(NSString *)origin options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler WK_API_AVAILABLE(macos(12.0), ios(15.0)); 143 150 - (void)makeCredentialWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 151 - (void)makeCredentialWithMediationRequirement:(_WKWebAuthenticationMediationRequirement)mediation clientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 144 152 - (void)getAssertionWithChallenge:(NSData *)challenge origin:(NSString *)origin options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler WK_API_AVAILABLE(macos(12.0), ios(15.0)); 145 153 - (void)getAssertionWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 154 - (void)getAssertionWithMediationRequirement:(_WKWebAuthenticationMediationRequirement)mediation clientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 146 155 - (void)cancel; 147 156 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r291176 r291625 49 49 #import <WebCore/CBORReader.h> 50 50 #import <WebCore/CBORWriter.h> 51 #import <WebCore/CredentialRequestOptions.h> 51 52 #import <WebCore/DeviceRequestConverter.h> 52 53 #import <WebCore/FidoConstants.h> … … 787 788 return result; 788 789 } 790 791 static WebCore::CredentialRequestOptions::MediationRequirement toWebCore(_WKWebAuthenticationMediationRequirement mediation) 792 { 793 switch (mediation) { 794 case _WKWebAuthenticationMediationRequirementSilent: 795 return WebCore::CredentialRequestOptions::MediationRequirement::Silent; 796 case _WKWebAuthenticationMediationRequirementOptional: 797 return WebCore::CredentialRequestOptions::MediationRequirement::Optional; 798 case _WKWebAuthenticationMediationRequirementRequired: 799 return WebCore::CredentialRequestOptions::MediationRequirement::Required; 800 case _WKWebAuthenticationMediationRequirementConditional: 801 return WebCore::CredentialRequestOptions::MediationRequirement::Conditional; 802 default: 803 ASSERT_NOT_REACHED(); 804 return WebCore::CredentialRequestOptions::MediationRequirement::Optional; 805 } 806 } 789 807 #endif 790 808 … … 845 863 } 846 864 847 - (void)makeCredentialWith ClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler865 - (void)makeCredentialWithMediationRequirement:(_WKWebAuthenticationMediationRequirement)mediation clientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler 848 866 { 849 867 #if ENABLE(WEB_AUTHN) … … 855 873 }); 856 874 }; 857 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 858 #endif 875 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, toWebCore(mediation), std::nullopt }, WTFMove(callback)); 876 #endif 877 } 878 879 - (void)makeCredentialWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialCreationOptions *)options completionHandler:(void (^)(_WKAuthenticatorAttestationResponse *, NSError *))handler 880 { 881 [self makeCredentialWithMediationRequirement:_WKWebAuthenticationMediationRequirementOptional clientDataHash:clientDataHash options:options completionHandler:handler]; 859 882 } 860 883 … … 909 932 } 910 933 911 - (void)getAssertionWith ClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler934 - (void)getAssertionWithMediationRequirement:(_WKWebAuthenticationMediationRequirement)mediation clientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler 912 935 { 913 936 #if ENABLE(WEB_AUTHN) … … 919 942 }); 920 943 }; 921 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 922 #endif 944 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, toWebCore(mediation), std::nullopt }, WTFMove(callback)); 945 #endif 946 } 947 948 - (void)getAssertionWithClientDataHash:(NSData *)clientDataHash options:(_WKPublicKeyCredentialRequestOptions *)options completionHandler:(void (^)(_WKAuthenticatorAssertionResponse *, NSError *))handler 949 { 950 [self getAssertionWithMediationRequirement:_WKWebAuthenticationMediationRequirementOptional clientDataHash:clientDataHash options:options completionHandler:handler]; 923 951 } 924 952 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp
r290893 r291625 282 282 { 283 283 ASSERT(RunLoop::isMain()); 284 if (!m_requestTimeOutTimer.isActive() )284 if (!m_requestTimeOutTimer.isActive() && (m_pendingRequestData.mediation != WebCore::CredentialRequestOptions::MediationRequirement::Conditional || !m_pendingCompletionHandler)) 285 285 return; 286 286 ASSERT(m_pendingCompletionHandler); … … 426 426 void AuthenticatorManager::initTimeOutTimer() 427 427 { 428 if (m_pendingRequestData.mediation == WebCore::CredentialRequestOptions::MediationRequirement::Conditional) 429 return; 428 430 std::optional<unsigned> timeOutInMs; 429 431 WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) { -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm
r291196 r291625 242 242 [requestContext setSecurityKeyCredentialCreationOptions:credentialCreationOptions.get()]; 243 243 244 if (options.extensions && [credentialCreationOptions respondsToSelector:@selector(setExtensions:)])244 if (options.extensions) 245 245 [credentialCreationOptions setExtensions:toASCExtensions(*options.extensions).get()]; 246 247 if (options.timeout && [credentialCreationOptions respondsToSelector:@selector(setTimeout:)]) 248 credentialCreationOptions.get().timeout = [NSNumber numberWithUnsignedInt:*options.timeout]; 246 249 247 250 return requestContext; … … 258 261 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 259 262 } 260 if (options.extensions && [assertionOptions respondsToSelector:@selector(setExtensions:)])263 if (options.extensions) 261 264 [assertionOptions setExtensions:toASCExtensions(*options.extensions).get()]; 262 265 if (parentOrigin && [assertionOptions respondsToSelector:@selector(setDestinationSiteForCrossSiteAssertion:)]) … … 264 267 else if (parentOrigin && ![assertionOptions respondsToSelector:@selector(setDestinationSiteForCrossSiteAssertion:)]) 265 268 return nil; 269 if (options.timeout && [assertionOptions respondsToSelector:@selector(setTimeout:)]) 270 assertionOptions.get().timeout = [NSNumber numberWithUnsignedInt:*options.timeout]; 266 271 return assertionOptions; 267 272 } -
trunk/Tools/ChangeLog
r291619 r291625 1 2022-03-22 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Pass along timeout to ASA and ignore timeout for conditional mediation requests 4 https://bugs.webkit.org/show_bug.cgi?id=238147 5 rdar://90509464 6 7 Reviewed by Brent Fulgham. 8 9 Modify API test to use new SPI. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm: 12 (TestWebKitAPI::TEST): 13 1 14 2022-03-21 Jonathan Bedard <jbedard@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm
r290652 r291625 1868 1868 } 1869 1869 1870 TEST(WebAuthenticationPanel, MakeCredentialLAClientDataHash )1870 TEST(WebAuthenticationPanel, MakeCredentialLAClientDataHashMediation) 1871 1871 { 1872 1872 reset(); … … 1889 1889 [panel setDelegate:delegate.get()]; 1890 1890 1891 [panel makeCredentialWith ClientDataHash:nsHash.get() options:options.get() completionHandler:^(_WKAuthenticatorAttestationResponse *response, NSError *error) {1891 [panel makeCredentialWithMediationRequirement:_WKWebAuthenticationMediationRequirementOptional clientDataHash:nsHash.get() options:options.get() completionHandler:^(_WKAuthenticatorAttestationResponse *response, NSError *error) { 1892 1892 webAuthenticationPanelRan = true; 1893 1893 cleanUpKeychain("example.com"); … … 2089 2089 } 2090 2090 2091 TEST(WebAuthenticationPanel, GetAssertionLAClientDataHash )2091 TEST(WebAuthenticationPanel, GetAssertionLAClientDataHashMediation) 2092 2092 { 2093 2093 reset(); … … 2106 2106 [panel setDelegate:delegate.get()]; 2107 2107 2108 [panel getAssertionWith ClientDataHash:nsHash options:options.get() completionHandler:^(_WKAuthenticatorAssertionResponse *response, NSError *error) {2108 [panel getAssertionWithMediationRequirement:_WKWebAuthenticationMediationRequirementOptional clientDataHash:nsHash options:options.get() completionHandler:^(_WKAuthenticatorAssertionResponse *response, NSError *error) { 2109 2109 webAuthenticationPanelRan = true; 2110 2110 cleanUpKeychain("example.com");
Note: See TracChangeset
for help on using the changeset viewer.