Changeset 291018 in webkit
- Timestamp:
- Mar 8, 2022 3:51:45 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 20 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/webauthn/public-key-credential-cross-origin.https-expected.txt (added)
-
LayoutTests/http/wpt/webauthn/public-key-credential-cross-origin.https.html (added)
-
LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt (modified) (1 diff)
-
LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html (modified) (2 diffs)
-
LayoutTests/http/wpt/webauthn/resources/public-key-credential-cross-origin.https.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h (modified) (1 diff)
-
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h (modified) (2 diffs)
-
Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h (modified) (3 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (modified) (5 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in (modified) (1 diff)
-
Source/WebKit/WebAuthnProcess/WebAuthnConnectionToWebProcess.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp (modified) (3 diffs)
-
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291009 r291018 1 2022-03-08 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Using WebAuthn within cross-origin iframe elements 4 https://bugs.webkit.org/show_bug.cgi?id=222240 5 rdar://problem/74830748 6 7 Reviewed by Brent Fulgham. 8 9 Update existing tests and create new test for cross-origin, non same-site i-frames. 10 11 * http/wpt/webauthn/public-key-credential-cross-origin.https-expected.txt: Added. 12 * http/wpt/webauthn/public-key-credential-cross-origin.https.html: Added. 13 * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: 14 * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html: 15 * http/wpt/webauthn/resources/public-key-credential-cross-origin.https.html: Added. 16 1 17 2022-03-08 Chris Fleizach <cfleizach@apple.com> 2 18 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt
r287116 r291018 5 5 PASS Tests that a frame that is same-site, cross-origin without publickey-credentials-get feature policy cannot use get(). 6 6 PASS Tests that a frame that is same-site, cross-origin with publickey-credentials-get feature policy can use get(). 7 PASS Tests that a frame that is cross-origin, NOT same-sitewith publickey-credentials-get feature policy cannot use get().7 PASS Tests that a frame using an ip address that is cross-origin, NOT same-site with publickey-credentials-get feature policy cannot use get(). 8 8 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html
r287116 r291018 1 <!DOCTYPE html><!-- webkit-test-runner [ WebAuthenticationModernEnabled= true ] -->1 <!DOCTYPE html><!-- webkit-test-runner [ WebAuthenticationModernEnabled=false ] --> 2 2 <html> 3 3 <head> … … 38 38 promise_test(t => { 39 39 return withCrossOriginIframe("samesite-iframe.html", "publickey-credentials-get").then((message) => { 40 assert_equals(message.data, "Throw NotAllowedError: The origin of the document is not the same as its ancestors.");40 assert_equals(message.data, "Throw SecurityError: The effective domain of the document is not a valid domain."); 41 41 }); 42 }, "Tests that a frame that is cross-origin, NOT same-sitewith publickey-credentials-get feature policy cannot use get().");42 }, "Tests that a frame using an ip address that is cross-origin, NOT same-site with publickey-credentials-get feature policy cannot use get()."); 43 43 </script> 44 44 </body> -
trunk/Source/WebCore/ChangeLog
r291017 r291018 1 2022-03-08 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Using WebAuthn within cross-origin iframe elements 4 https://bugs.webkit.org/show_bug.cgi?id=222240 5 rdar://problem/74830748 6 7 Reviewed by Brent Fulgham. 8 9 This patch relaxes the requirement to perform a Web Authentication assertion 10 inside an i-frame with the "publickey-credentials-get" feature policy from 11 'same-site' to 'cross-origin with consent'. 12 13 There is an additional requirement that there is only a single cross-origin 14 parent to present to the user in the prompt. If we can't display the updated 15 prompt, then cross-origin assertions are not allowed. 16 17 Test: http/wpt/webauthn/public-key-credential-cross-origin.https.html 18 19 * Modules/credentialmanagement/CredentialsContainer.cpp: 20 (WebCore::CredentialsContainer::scopeAndSingleParent): 21 (WebCore::CredentialsContainer::get): 22 (WebCore::CredentialsContainer::isCreate): 23 (WebCore::CredentialsContainer::scope): Deleted. 24 * Modules/credentialmanagement/CredentialsContainer.h: 25 * Modules/webauthn/AuthenticatorCoordinator.cpp: 26 (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const): 27 * Modules/webauthn/AuthenticatorCoordinator.h: 28 * Modules/webauthn/AuthenticatorCoordinatorClient.h: 29 1 30 2022-03-08 Chris Dumez <cdumez@apple.com> 2 31 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
r290184 r291018 47 47 } 48 48 49 WebAuthn::Scope CredentialsContainer::scope() 49 ScopeAndCrossOriginParent CredentialsContainer::scopeAndCrossOriginParent() const 50 50 { 51 51 if (!m_document) 52 return WebAuthn::Scope::CrossOrigin;52 return std::pair { WebAuthn::Scope::CrossOrigin, std::nullopt }; 53 53 54 bool isSameOrigin = true;55 54 bool isSameSite = true; 56 55 auto& origin = m_document->securityOrigin(); 57 56 auto& url = m_document->url(); 57 std::optional<SecurityOriginData> crossOriginParent; 58 58 for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) { 59 59 if (!origin.isSameOriginDomain(document->securityOrigin()) && !areRegistrableDomainsEqual(url, document->url())) 60 60 isSameSite = false; 61 if (! origin.isSameOriginAs(document->securityOrigin()))62 isSameOrigin = false;61 if (!crossOriginParent && !origin.isSameOriginAs(document->securityOrigin())) 62 crossOriginParent = origin.data(); 63 63 } 64 64 65 if ( isSameOrigin)66 return WebAuthn::Scope::SameOrigin;65 if (!crossOriginParent) 66 return std::pair { WebAuthn::Scope::SameOrigin, std::nullopt }; 67 67 if (isSameSite) 68 return WebAuthn::Scope::SameSite;69 return WebAuthn::Scope::CrossOrigin;68 return std::pair { WebAuthn::Scope::SameSite, std::nullopt }; 69 return std::pair { WebAuthn::Scope::CrossOrigin, crossOriginParent }; 70 70 } 71 71 … … 99 99 } 100 100 101 m_document->page()->authenticatorCoordinator().discoverFromExternalSource(*m_document, WTFMove(options), scope (), WTFMove(promise));101 m_document->page()->authenticatorCoordinator().discoverFromExternalSource(*m_document, WTFMove(options), scopeAndCrossOriginParent(), WTFMove(promise)); 102 102 } 103 103 … … 134 134 } 135 135 136 m_document->page()->authenticatorCoordinator().create(*m_document, options.publicKey.value(), scope (), WTFMove(options.signal), WTFMove(promise));136 m_document->page()->authenticatorCoordinator().create(*m_document, options.publicKey.value(), scopeAndCrossOriginParent().first, WTFMove(options.signal), WTFMove(promise)); 137 137 } 138 138 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
r287116 r291018 59 59 CredentialsContainer(WeakPtr<Document>&&); 60 60 61 WebAuthn::Scope scope();61 ScopeAndCrossOriginParent scopeAndCrossOriginParent() const; 62 62 63 63 WeakPtr<Document> m_document; -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
r290515 r291018 185 185 } 186 186 187 void AuthenticatorCoordinator::discoverFromExternalSource(const Document& document, CredentialRequestOptions&& requestOptions, WebAuthn::Scope scope, CredentialPromise&& promise) const187 void AuthenticatorCoordinator::discoverFromExternalSource(const Document& document, CredentialRequestOptions&& requestOptions, const ScopeAndCrossOriginParent& scopeAndCrossOriginParent, CredentialPromise&& promise) const 188 188 { 189 189 using namespace AuthenticatorCoordinatorInternal; … … 196 196 // Step 1, 3, 13 are handled by the caller. 197 197 // Step 2. 198 // This implements https://www.w3.org/TR/webauthn-2/#sctn-permissions-policy except only same-site, cross-origin is permitted.199 if (scope != WebAuthn::Scope::SameOrigin && !(scope == WebAuthn::Scope::SameSite && isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::PublickeyCredentialsGetRule, document, LogFeaturePolicyFailure::No))) {198 // This implements https://www.w3.org/TR/webauthn-2/#sctn-permissions-policy 199 if (scopeAndCrossOriginParent.first != WebAuthn::Scope::SameOrigin && !isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::PublickeyCredentialsGetRule, document, LogFeaturePolicyFailure::No)) { 200 200 promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 201 201 return; … … 231 231 232 232 // Step 10-12. 233 auto clientDataJson = buildClientDataJson(ClientDataType::Get, options.challenge, callerOrigin, scope );233 auto clientDataJson = buildClientDataJson(ClientDataType::Get, options.challenge, callerOrigin, scopeAndCrossOriginParent.first); 234 234 auto clientDataJsonHash = buildClientDataJsonHash(clientDataJson); 235 235 … … 255 255 }; 256 256 // Async operations are dispatched and handled in the messenger. 257 m_client->getAssertion(*frame, callerOrigin, clientDataJsonHash, options, requestOptions.mediation, WTFMove(callback));257 m_client->getAssertion(*frame, callerOrigin, clientDataJsonHash, options, requestOptions.mediation, scopeAndCrossOriginParent, WTFMove(callback)); 258 258 } 259 259 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h
r290184 r291018 46 46 struct PublicKeyCredentialRequestOptions; 47 47 struct CredentialRequestOptions; 48 struct SecurityOriginData; 48 49 49 50 template<typename IDLType> class DOMPromiseDeferred; 50 51 51 52 using CredentialPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<BasicCredential>>>; 53 using ScopeAndCrossOriginParent = std::pair<WebAuthn::Scope, std::optional<SecurityOriginData>>; 52 54 53 55 class AuthenticatorCoordinator final { … … 60 62 // The following methods implement static methods of PublicKeyCredential. 61 63 void create(const Document&, const PublicKeyCredentialCreationOptions&, WebAuthn::Scope, RefPtr<AbortSignal>&&, CredentialPromise&&) const; 62 void discoverFromExternalSource(const Document&, CredentialRequestOptions&&, WebAuthn::Scope, CredentialPromise&&) const;64 void discoverFromExternalSource(const Document&, CredentialRequestOptions&&, const ScopeAndCrossOriginParent&, CredentialPromise&&) const; 63 65 void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&) const; 64 66 void isConditionalMediationAvailable(DOMPromiseDeferred<IDLBoolean>&&) const; -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h
r290184 r291018 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include "AuthenticatorCoordinator.h" 30 31 #include "ExceptionData.h" 31 32 #include <wtf/CompletionHandler.h> 32 33 #include <wtf/WeakPtr.h> 34 35 namespace WebAuthn { 36 enum class Scope; 37 } 33 38 34 39 namespace WebCore { … … 44 49 struct PublicKeyCredentialCreationOptions; 45 50 struct PublicKeyCredentialRequestOptions; 51 struct SecurityOriginData; 46 52 47 53 using RequestCompletionHandler = CompletionHandler<void(WebCore::AuthenticatorResponseData&&, WebCore::AuthenticatorAttachment, WebCore::ExceptionData&&)>; … … 56 62 57 63 virtual void makeCredential(const Frame&, const SecurityOrigin&, const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) = 0; 58 virtual void getAssertion(const Frame&, const SecurityOrigin&, const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, MediationRequirement, RequestCompletionHandler&&) = 0;64 virtual void getAssertion(const Frame&, const SecurityOrigin&, const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, MediationRequirement, const ScopeAndCrossOriginParent&, RequestCompletionHandler&&) = 0; 59 65 virtual void isConditionalMediationAvailable(QueryCompletionHandler&&) = 0; 60 66 virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) = 0; -
trunk/Source/WebKit/ChangeLog
r291017 r291018 1 2022-03-08 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Using WebAuthn within cross-origin iframe elements 4 https://bugs.webkit.org/show_bug.cgi?id=222240 5 rdar://problem/74830748 6 7 Reviewed by Brent Fulgham. 8 9 This patch relaxes the requirement to perform a Web Authentication assertion 10 inside an i-frame with the "publickey-credentials-get" feature policy from 11 'same-site' to 'cross-origin with consent'. 12 13 There is an additional requirement that there is only a single cross-origin 14 parent to present to the user in the prompt. If we can't display the updated 15 prompt, then cross-origin assertions are not allowed. 16 17 * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h: 18 * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: 19 (WebKit::configureAssertionOptions): 20 (WebKit::configurationAssertionRequestContext): 21 (WebKit::WebAuthenticatorCoordinatorProxy::contextForRequest): 22 * UIProcess/WebAuthentication/WebAuthenticationRequestData.h: 23 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: 24 (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential): 25 (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion): 26 (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest): 27 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: 28 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: 29 * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: 30 (WebKit::WebAuthenticatorCoordinator::getAssertion): 31 * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h: 32 1 33 2022-03-08 Chris Dumez <cdumez@apple.com> 2 34 -
trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h
r290893 r291018 168 168 @property (nonatomic, nullable, readonly, copy) NSArray<ASCPublicKeyCredentialDescriptor *> *allowedCredentials; 169 169 170 @property (nonatomic, nullable, copy) NSString *destinationSiteForCrossSiteAssertion; 171 170 172 @end 171 173 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r290381 r291018 823 823 }); 824 824 }; 825 _panel->handleRequest({ WTFMove(hash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt }, WTFMove(callback));825 _panel->handleRequest({ WTFMove(hash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 826 826 #endif 827 827 } … … 837 837 }); 838 838 }; 839 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt }, WTFMove(callback));839 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 840 840 #endif 841 841 } … … 887 887 }); 888 888 }; 889 _panel->handleRequest({ WTFMove(hash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt }, WTFMove(callback));889 _panel->handleRequest({ WTFMove(hash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 890 890 #endif 891 891 } … … 901 901 }); 902 902 }; 903 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt }, WTFMove(callback));903 _panel->handleRequest({ vectorFromNSData(clientDataHash), [_WKWebAuthenticationPanel convertToCoreRequestOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(callback)); 904 904 #endif 905 905 } -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm
r290893 r291018 173 173 } 174 174 175 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options, Vector<uint8_t> hash) 175 static inline void setGlobalFrameIDForContext(RetainPtr<ASCCredentialRequestContext> requestContext, std::optional<WebCore::GlobalFrameIdentifier> globalFrameID) 176 { 177 if (globalFrameID && [requestContext respondsToSelector:@selector(setGlobalFrameID:)]) { 178 auto ascGlobalFrameID = adoptNS([allocASCGlobalFrameIdentifierInstance() init]); 179 ascGlobalFrameID.get().webFrameID = [NSNumber numberWithUnsignedLong:globalFrameID->frameID.toUInt64()]; 180 ascGlobalFrameID.get().webPageID = [NSNumber numberWithUnsignedLong:globalFrameID->pageID.toUInt64()]; 181 requestContext.get().globalFrameID = ascGlobalFrameID.get(); 182 } 183 } 184 185 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options, const Vector<uint8_t>& hash, std::optional<WebCore::GlobalFrameIdentifier> globalFrameID) 176 186 { 177 187 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration | ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration; … … 194 204 auto requestContext = adoptNS([allocASCCredentialRequestContextInstance() initWithRequestTypes:requestTypes]); 195 205 [requestContext setRelyingPartyIdentifier:options.rp.id]; 206 setGlobalFrameIDForContext(requestContext, globalFrameID); 196 207 197 208 auto credentialCreationOptions = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]); … … 237 248 } 238 249 239 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options, Vector<uint8_t> hash, std::optional<WebCore::MediationRequirement> mediation, std::optional<WebCore::GlobalFrameIdentifier> globalFrameID) 250 static inline RetainPtr<ASCPublicKeyCredentialAssertionOptions> configureAssertionOptions(const PublicKeyCredentialRequestOptions& options, const Vector<uint8_t>& hash, ASCPublicKeyCredentialKind kind, const std::optional<SecurityOriginData>& parentOrigin, RetainPtr<NSMutableArray<ASCPublicKeyCredentialDescriptor *>> allowedCredentials, RetainPtr<NSString> userVerification) 251 { 252 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 253 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 254 auto nsHash = toNSData(hash); 255 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId clientDataHash:nsHash.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 256 } else { 257 auto challenge = WebCore::toNSData(options.challenge); 258 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 259 } 260 if (options.extensions && [assertionOptions respondsToSelector:@selector(setExtensions:)]) 261 [assertionOptions setExtensions:toASCExtensions(*options.extensions).get()]; 262 if (parentOrigin && [assertionOptions respondsToSelector:@selector(setDestinationSiteForCrossSiteAssertion:)]) 263 assertionOptions.get().destinationSiteForCrossSiteAssertion = parentOrigin->toString(); 264 else if (parentOrigin && ![assertionOptions respondsToSelector:@selector(setDestinationSiteForCrossSiteAssertion:)]) 265 return nil; 266 return assertionOptions; 267 } 268 269 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options, const Vector<uint8_t>& hash, std::optional<WebCore::MediationRequirement> mediation, std::optional<WebCore::GlobalFrameIdentifier> globalFrameID, std::optional<WebCore::SecurityOriginData>& parentOrigin) 240 270 { 241 271 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyAssertion | ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion; … … 263 293 if (mediation == MediationRequirement::Conditional && [requestContext respondsToSelector:@selector(setRequestStyle:)]) 264 294 requestContext.get().requestStyle = ASCredentialRequestStyleAutoFill; 265 if (globalFrameID && [requestContext respondsToSelector:@selector(setGlobalFrameID:)]) { 266 auto ascGlobalFrameID = adoptNS([allocASCGlobalFrameIdentifierInstance() init]); 267 ascGlobalFrameID.get().webFrameID = [NSNumber numberWithUnsignedLong:globalFrameID->frameID.toUInt64()]; 268 ascGlobalFrameID.get().webPageID = [NSNumber numberWithUnsignedLong:globalFrameID->pageID.toUInt64()]; 269 requestContext.get().globalFrameID = ascGlobalFrameID.get(); 270 } 295 setGlobalFrameIDForContext(requestContext, globalFrameID); 271 296 272 297 if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion) { 273 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 274 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 275 auto nsHash = toNSData(hash); 276 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId clientDataHash:nsHash.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 277 } else { 278 auto challenge = WebCore::toNSData(options.challenge); 279 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 280 } 281 if (options.extensions && [assertionOptions respondsToSelector:@selector(setExtensions:)]) 282 [assertionOptions setExtensions:toASCExtensions(*options.extensions).get()]; 283 298 auto assertionOptions = configureAssertionOptions(options, hash, ASCPublicKeyCredentialKindPlatform, parentOrigin, allowedCredentials, userVerification); 299 if (!assertionOptions) 300 return nil; 284 301 [requestContext setPlatformKeyCredentialAssertionOptions:assertionOptions.get()]; 285 302 } 286 303 287 304 if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion) { 288 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 289 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 290 auto nsHash = toNSData(hash); 291 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId clientDataHash:nsHash.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 292 } else { 293 auto challenge = WebCore::toNSData(options.challenge); 294 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 295 } 296 if (options.extensions && [assertionOptions respondsToSelector:@selector(setExtensions:)]) 297 [assertionOptions setExtensions:toASCExtensions(*options.extensions).get()]; 298 305 auto assertionOptions = configureAssertionOptions(options, hash, ASCPublicKeyCredentialKindSecurityKey, parentOrigin, allowedCredentials, userVerification); 306 if (!assertionOptions) 307 return nil; 299 308 [requestContext setSecurityKeyCredentialAssertionOptions:assertionOptions.get()]; 300 309 } … … 307 316 RetainPtr<ASCCredentialRequestContext> result; 308 317 WTF::switchOn(requestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 309 result = configureRegistrationRequestContext(options, requestData.hash );318 result = configureRegistrationRequestContext(options, requestData.hash, requestData.globalFrameID); 310 319 }, [&](const PublicKeyCredentialRequestOptions& options) { 311 result = configurationAssertionRequestContext(options, requestData.hash, requestData.mediation, requestData.globalFrameID );320 result = configurationAssertionRequestContext(options, requestData.hash, requestData.mediation, requestData.globalFrameID, requestData.parentOrigin); 312 321 }); 313 322 return result; -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h
r290893 r291018 40 40 #include <wtf/WeakPtr.h> 41 41 42 namespace WebCore { 43 struct SecurityOriginData; 44 } 45 42 46 namespace WebKit { 43 47 … … 59 63 WeakPtr<API::WebAuthenticationPanel> weakPanel; 60 64 std::optional<WebCore::MediationRequirement> mediation; 65 std::optional<WebCore::SecurityOriginData> parentOrigin; 61 66 }; 62 67 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
r290184 r291018 59 59 void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler) 60 60 { 61 handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr, std::nullopt }, WTFMove(handler));61 handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(handler)); 62 62 } 63 63 64 void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, MediationRequirement mediation, bool processingUserGesture, RequestCompletionHandler&& handler)64 void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, MediationRequirement mediation, std::optional<WebCore::SecurityOriginData> parentOrigin, bool processingUserGesture, RequestCompletionHandler&& handler) 65 65 { 66 handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr, mediation }, WTFMove(handler));66 handleRequest({ WTFMove(hash), WTFMove(options), m_webPageProxy, WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr, mediation, parentOrigin }, WTFMove(handler)); 67 67 } 68 68 … … 75 75 if (result) { 76 76 #if HAVE(UNIFIED_ASC_AUTH_UI) 77 if (!authenticatorManager.isMock() && !authenticatorManager.isVirtual()) { 78 auto context = contextForRequest(WTFMove(data)); 79 // performRequest calls out to ASCAgent which will then call [_WKWebAuthenticationPanel makeCredential/getAssertionWithChallenge] 80 // which calls authenticatorManager.handleRequest(..) 81 performRequest(context, WTFMove(handler)); 77 if (!authenticatorManager.isMock() && !authenticatorManager.isVirtual()) { 78 auto context = contextForRequest(WTFMove(data)); 79 if (context.get() == nullptr) { 80 handler({ }, (AuthenticatorAttachment)0, ExceptionData { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 82 81 return; 83 82 } 83 // performRequest calls out to ASCAgent which will then call [_WKWebAuthenticationPanel makeCredential/getAssertionWithChallenge] 84 // which calls authenticatorManager.handleRequest(..) 85 performRequest(context, WTFMove(handler)); 86 return; 87 } 88 #else 89 if (data.parentOrigin && !authenticatorManager.isMock() && !authenticatorManager.isVirtual()) { 90 handler({ }, (AuthenticatorAttachment)0, ExceptionData { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 91 return; 92 } 84 93 #endif // HAVE(UNIFIED_ASC_AUTH_UI) 85 94 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h
r290317 r291018 72 72 // Receivers. 73 73 void makeCredential(WebCore::FrameIdentifier, FrameInfoData&&, Vector<uint8_t>&& hash, WebCore::PublicKeyCredentialCreationOptions&&, bool processingUserGesture, RequestCompletionHandler&&); 74 void getAssertion(WebCore::FrameIdentifier, FrameInfoData&&, Vector<uint8_t>&& hash, WebCore::PublicKeyCredentialRequestOptions&&, WebCore::CredentialRequestOptions::MediationRequirement, bool processingUserGesture, RequestCompletionHandler&&);74 void getAssertion(WebCore::FrameIdentifier, FrameInfoData&&, Vector<uint8_t>&& hash, WebCore::PublicKeyCredentialRequestOptions&&, WebCore::CredentialRequestOptions::MediationRequirement, std::optional<WebCore::SecurityOriginData>, bool processingUserGesture, RequestCompletionHandler&&); 75 75 void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&); 76 76 void isConditionalMediationAvailable(QueryCompletionHandler&&); -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in
r290903 r291018 28 28 29 29 MakeCredential(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options, bool processingUserGesture) -> (struct WebCore::AuthenticatorResponseData data, enum:int WebCore::AuthenticatorAttachment attachment, struct WebCore::ExceptionData exception) 30 GetAssertion(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options, enum:uint8_t WebCore::CredentialRequestOptions::MediationRequirement mediation, bool processingUserGesture) -> (struct WebCore::AuthenticatorResponseData data, enum:int WebCore::AuthenticatorAttachment attachment, struct WebCore::ExceptionData exception)30 GetAssertion(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options, enum:uint8_t WebCore::CredentialRequestOptions::MediationRequirement mediation, std::optional<WebCore::SecurityOriginData> parentOrigin, bool processingUserGesture) -> (struct WebCore::AuthenticatorResponseData data, enum:int WebCore::AuthenticatorAttachment attachment, struct WebCore::ExceptionData exception) 31 31 isConditionalMediationAvailable() -> (bool result) 32 32 IsUserVerifyingPlatformAuthenticatorAvailable() -> (bool result) -
trunk/Source/WebKit/WebAuthnProcess/WebAuthnConnectionToWebProcess.cpp
r290184 r291018 97 97 void WebAuthnConnectionToWebProcess::makeCredential(Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler) 98 98 { 99 handleRequest({ WTFMove(hash), WTFMove(options), nullptr, WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, processingUserGesture, String(), nullptr, std::nullopt }, WTFMove(handler));99 handleRequest({ WTFMove(hash), WTFMove(options), nullptr, WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, processingUserGesture, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(handler)); 100 100 } 101 101 102 102 void WebAuthnConnectionToWebProcess::getAssertion(Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler) 103 103 { 104 handleRequest({ WTFMove(hash), WTFMove(options), nullptr, WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, processingUserGesture, String(), nullptr, std::nullopt }, WTFMove(handler));104 handleRequest({ WTFMove(hash), WTFMove(options), nullptr, WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, processingUserGesture, String(), nullptr, std::nullopt, std::nullopt }, WTFMove(handler)); 105 105 } 106 106 -
trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
r290755 r291018 47 47 #include <WebCore/SecurityOrigin.h> 48 48 #include <WebCore/UserGestureIndicator.h> 49 #include <WebCore/WebAuthenticationConstants.h> 49 50 50 51 #undef WEBAUTHN_RELEASE_LOG … … 94 95 } 95 96 96 void WebAuthenticatorCoordinator::getAssertion(const Frame& frame, const SecurityOrigin&, const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, MediationRequirement mediation, RequestCompletionHandler&& handler)97 void WebAuthenticatorCoordinator::getAssertion(const Frame& frame, const SecurityOrigin&, const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, MediationRequirement mediation, const ScopeAndCrossOriginParent& scopeAndCrossOriginParent, RequestCompletionHandler&& handler) 97 98 { 98 99 auto* webFrame = WebFrame::fromCoreFrame(frame); … … 107 108 #endif 108 109 if (!useWebAuthnProcess) { 109 m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(webFrame->frameID(), webFrame->info(), hash, options, mediation, isProcessingUserGesture), WTFMove(handler)); 110 m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(webFrame->frameID(), webFrame->info(), hash, options, mediation, scopeAndCrossOriginParent.second, isProcessingUserGesture), WTFMove(handler)); 111 return; 112 } 113 if (scopeAndCrossOriginParent.first == WebAuthn::Scope::CrossOrigin) { 114 handler({ }, (AuthenticatorAttachment)0, ExceptionData { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 110 115 return; 111 116 } -
trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h
r290184 r291018 42 42 // WebCore::AuthenticatorCoordinatorClient 43 43 void makeCredential(const WebCore::Frame&, const WebCore::SecurityOrigin&, const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::RequestCompletionHandler&&) final; 44 void getAssertion(const WebCore::Frame&, const WebCore::SecurityOrigin&, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::MediationRequirement, WebCore::RequestCompletionHandler&&) final;44 void getAssertion(const WebCore::Frame&, const WebCore::SecurityOrigin&, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::MediationRequirement, const std::pair<WebAuthn::Scope, std::optional<WebCore::SecurityOriginData>>&, WebCore::RequestCompletionHandler&&) final; 45 45 void isConditionalMediationAvailable(WebCore::QueryCompletionHandler&&) final; 46 46 void isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&&) final;
Note: See TracChangeset
for help on using the changeset viewer.