Changeset 286993 in webkit
- Timestamp:
- Dec 13, 2021 3:58:25 PM (7 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
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) (1 diff)
-
LayoutTests/http/wpt/webauthn/resources/samesite-iframe.html (added)
-
LayoutTests/http/wpt/webauthn/resources/util.js (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h (modified) (2 diffs)
-
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp (modified) (7 diffs)
-
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h (modified) (2 diffs)
-
Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (modified) (1 diff)
-
Source/WebCore/Modules/webauthn/WebAuthenticationUtils.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webauthn/WebAuthenticationUtils.h (modified) (1 diff)
-
Source/WebCore/html/FeaturePolicy.cpp (modified) (5 diffs)
-
Source/WebCore/html/FeaturePolicy.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r286990 r286993 1 2021-12-13 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Allow same-site, cross-origin iframe get() 4 https://bugs.webkit.org/show_bug.cgi?id=234180 5 rdar://85161142 6 7 Reviewed by Brent Fulgham. 8 9 Add layout test for WebAuthn get assertions on cross-site, same-sites i-frames with 10 publickey-credentials-get feature policy. 11 12 * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: 13 * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html: 14 * http/wpt/webauthn/resources/util.js: 15 1 16 2021-12-13 Ryan Haddad <ryanhaddad@apple.com> 2 17 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt
r267644 r286993 3 3 PASS Tests that a frame that doesn't share the same origin with all its ancestors could not access the API. 4 4 PASS Tests that a frame that doesn't share the same origin with all its ancestors could not access the API. 2 5 PASS Tests that a frame that is same-site, cross-origin without publickey-credentials-get feature policy cannot use get(). 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-site with publickey-credentials-get feature policy cannot use get(). 5 8 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html
r269360 r286993 23 23 }); 24 24 }, "Tests that a frame that doesn't share the same origin with all its ancestors could not access the API. 2"); 25 26 promise_test(t => { 27 return withSameSiteIframe("samesite-iframe.html").then((message) => { 28 assert_equals(message.data, "Throw NotAllowedError: The origin of the document is not the same as its ancestors."); 29 }); 30 }, "Tests that a frame that is same-site, cross-origin without publickey-credentials-get feature policy cannot use get()."); 31 32 promise_test(t => { 33 return withSameSiteIframe("samesite-iframe.html", "publickey-credentials-get").then((message) => { 34 assert_equals(message.data, "PASS!"); 35 }); 36 }, "Tests that a frame that is same-site, cross-origin with publickey-credentials-get feature policy can use get()."); 37 38 promise_test(t => { 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."); 41 }); 42 }, "Tests that a frame that is cross-origin, NOT same-site with publickey-credentials-get feature policy cannot use get()."); 25 43 </script> 26 44 </body> -
trunk/LayoutTests/http/wpt/webauthn/resources/util.js
r263438 r286993 305 305 } 306 306 307 function withCrossOriginIframe(resourceFile )307 function withCrossOriginIframe(resourceFile, allow = "") 308 308 { 309 309 return new Promise((resolve) => { … … 312 312 }); 313 313 const frame = document.createElement("iframe"); 314 frame.allow = allow; 314 315 frame.src = get_host_info().HTTPS_REMOTE_ORIGIN + RESOURCES_DIR + resourceFile; 315 316 document.body.appendChild(frame); 317 }); 318 } 319 320 function withSameSiteIframe(resourceFile, allow = "") 321 { 322 return new Promise((resolve) => { 323 waitForLoad().then((message) => { 324 resolve(message); 325 }); 326 const frame = document.createElement("iframe"); 327 const host = get_host_info(); 328 frame.allow = allow; 329 frame.src = "https://" + host.ORIGINAL_HOST + ":" + host.HTTPS_PORT2 + RESOURCES_DIR + resourceFile; 330 document.body.appendChild(frame); 316 331 }); 317 332 } -
trunk/Source/WebCore/ChangeLog
r286988 r286993 1 2021-12-13 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Allow same-site, cross-origin iframe get() 4 https://bugs.webkit.org/show_bug.cgi?id=234180 5 rdar://85161142 6 7 Reviewed by Brent Fulgham. 8 9 The Web Authentication level 2 specifies a feature policy to allow get calls in 10 cross-origin i-frames. This patch implements this feature policy partially. Only 11 same-site, cross-origin i-frames are supported instead. This is for tracking prevention 12 purposes. https://w3c.github.io/webauthn/#sctn-iframe-guidance 13 14 This patch also starts passing ClientDataJSON hashes to ASC to avoid the situation 15 where WebKit includes crossOrigin or other fields in ClientDataJSON that ASC is 16 unaware of when generating ClientDataJSON. 17 18 Added layout test cases for same-site, cross-origin get calls. 19 20 * Modules/webauthn/AuthenticatorCoordinator.cpp: 21 (WebCore::AuthenticatorCoordinator::create const): 22 (WebCore::doesHaveSameSiteAsAncestors): 23 (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const): 24 * Modules/webauthn/WebAuthenticationUtils.cpp: 25 (WebCore::buildClientDataJson): 26 * Modules/webauthn/WebAuthenticationUtils.h: 27 * html/FeaturePolicy.cpp: 28 (WebCore::policyTypeName): 29 (WebCore::FeaturePolicy::parse): 30 (WebCore::FeaturePolicy::allows const): 31 * html/FeaturePolicy.h: 32 1 33 2021-12-13 Andreu Botella <andreu@andreubotella.com> 2 34 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
r251295 r286993 38 38 #include "Page.h" 39 39 #include "SecurityOrigin.h" 40 #include "WebAuthenticationConstants.h" 40 41 41 42 namespace WebCore { … … 46 47 } 47 48 48 bool CredentialsContainer::doesHaveSameOriginAsItsAncestors()49 WebAuthn::Scope CredentialsContainer::scope() 49 50 { 50 // The following implements https://w3c.github.io/webappsec-credential-management/#same-origin-with-its-ancestors51 // as of 14 November 2017.52 51 if (!m_document) 53 return false; 52 return WebAuthn::Scope::CrossOrigin; 53 54 bool isSameOrigin = true; 55 bool isSameSite = true; 56 auto& origin = m_document->securityOrigin(); 57 auto& url = m_document->url(); 58 for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) { 59 if (!origin.isSameOriginDomain(document->securityOrigin()) && !areRegistrableDomainsEqual(url, document->url())) 60 isSameSite = false; 61 if (!origin.isSameOriginAs(document->securityOrigin())) 62 isSameOrigin = false; 63 } 54 64 55 auto& origin = m_document->securityOrigin(); 56 for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) { 57 if (!origin.isSameOriginAs(document->securityOrigin())) 58 return false; 59 } 60 return true; 65 if (isSameOrigin) 66 return WebAuthn::Scope::SameOrigin; 67 if (isSameSite) 68 return WebAuthn::Scope::SameSite; 69 return WebAuthn::Scope::CrossOrigin; 61 70 } 62 71 … … 90 99 } 91 100 92 m_document->page()->authenticatorCoordinator().discoverFromExternalSource(*m_document, options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));101 m_document->page()->authenticatorCoordinator().discoverFromExternalSource(*m_document, options.publicKey.value(), scope(), WTFMove(options.signal), WTFMove(promise)); 93 102 } 94 103 … … 125 134 } 126 135 127 m_document->page()->authenticatorCoordinator().create(*m_document, options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));136 m_document->page()->authenticatorCoordinator().create(*m_document, options.publicKey.value(), scope(), WTFMove(options.signal), WTFMove(promise)); 128 137 } 129 138 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
r235888 r286993 33 33 #include <wtf/WeakPtr.h> 34 34 35 namespace WebAuthn { 36 enum class Scope; 37 } 38 35 39 namespace WebCore { 36 40 … … 55 59 CredentialsContainer(WeakPtr<Document>&&); 56 60 57 bool doesHaveSameOriginAsItsAncestors();61 WebAuthn::Scope scope(); 58 62 59 63 WeakPtr<Document> m_document; -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
r285617 r286993 35 35 #include "AuthenticatorResponseData.h" 36 36 #include "Document.h" 37 #include "FeaturePolicy.h" 37 38 #include "JSBasicCredential.h" 38 39 #include "JSDOMPromiseDeferred.h" … … 105 106 } 106 107 107 void AuthenticatorCoordinator::create(const Document& document, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const108 void AuthenticatorCoordinator::create(const Document& document, const PublicKeyCredentialCreationOptions& options, WebAuthn::Scope scope, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const 108 109 { 109 110 using namespace AuthenticatorCoordinatorInternal; … … 115 116 // Step 1, 3, 16 are handled by the caller. 116 117 // Step 2. 117 if ( !sameOriginWithAncestors) {118 if (scope != WebAuthn::Scope::SameOrigin) { 118 119 promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 119 120 return; … … 149 150 150 151 // Step 13-15. 151 auto clientDataJson = buildClientDataJson(ClientDataType::Create, options.challenge, callerOrigin );152 auto clientDataJson = buildClientDataJson(ClientDataType::Create, options.challenge, callerOrigin, scope); 152 153 auto clientDataJsonHash = buildClientDataJsonHash(clientDataJson); 153 154 … … 176 177 } 177 178 178 void AuthenticatorCoordinator::discoverFromExternalSource(const Document& document, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const179 void AuthenticatorCoordinator::discoverFromExternalSource(const Document& document, const PublicKeyCredentialRequestOptions& options, WebAuthn::Scope scope, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const 179 180 { 180 181 using namespace AuthenticatorCoordinatorInternal; … … 186 187 // Step 1, 3, 13 are handled by the caller. 187 188 // Step 2. 188 if (!sameOriginWithAncestors) { 189 // This implements https://www.w3.org/TR/webauthn-2/#sctn-permissions-policy except only same-site, cross-origin is permitted. 190 if (scope != WebAuthn::Scope::SameOrigin && !(scope == WebAuthn::Scope::SameSite && isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::PublickeyCredentialsGetRule, document, LogFeaturePolicyFailure::No))) { 189 191 promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s }); 190 192 return; … … 220 222 221 223 // Step 10-12. 222 auto clientDataJson = buildClientDataJson(ClientDataType::Get, options.challenge, callerOrigin );224 auto clientDataJson = buildClientDataJson(ClientDataType::Get, options.challenge, callerOrigin, scope); 223 225 auto clientDataJsonHash = buildClientDataJsonHash(clientDataJson); 224 226 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h
r272345 r286993 32 32 #include <wtf/Noncopyable.h> 33 33 34 namespace WebAuthn { 35 enum class Scope; 36 } 37 34 38 namespace WebCore { 35 39 … … 54 58 55 59 // The following methods implement static methods of PublicKeyCredential. 56 void create(const Document&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;57 void discoverFromExternalSource(const Document&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;60 void create(const Document&, const PublicKeyCredentialCreationOptions&, WebAuthn::Scope, RefPtr<AbortSignal>&&, CredentialPromise&&) const; 61 void discoverFromExternalSource(const Document&, const PublicKeyCredentialRequestOptions&, WebAuthn::Scope, RefPtr<AbortSignal>&&, CredentialPromise&&) const; 58 62 void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&) const; 59 63 -
trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h
r261118 r286993 81 81 82 82 } // namespace WebCore 83 84 namespace WebAuthn { 85 86 enum class Scope { 87 CrossOrigin, 88 SameOrigin, 89 SameSite 90 }; 91 92 } // namespace WebAuthn -
trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.cpp
r285617 r286993 135 135 136 136 // FIXME(181948): Add token binding ID. 137 Ref<ArrayBuffer> buildClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin )137 Ref<ArrayBuffer> buildClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin, WebAuthn::Scope scope) 138 138 { 139 139 auto object = JSON::Object::create(); … … 148 148 object->setString("challenge"_s, base64URLEncodeToString(challenge.data(), challenge.length())); 149 149 object->setString("origin"_s, origin.toRawString()); 150 if (scope != WebAuthn::Scope::SameOrigin) 151 object->setBoolean("crossOrigin"_s, scope != WebAuthn::Scope::SameOrigin); 150 152 151 153 auto utf8JSONString = object->toJSONString().utf8(); -
trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.h
r285617 r286993 53 53 WEBCORE_EXPORT Vector<uint8_t> buildAttestationObject(Vector<uint8_t>&& authData, String&& format, cbor::CBORValue::MapValue&& statementMap, const AttestationConveyancePreference&); 54 54 55 WEBCORE_EXPORT Ref<ArrayBuffer> buildClientDataJson(ClientDataType /*type*/, const BufferSource& challenge, const SecurityOrigin& /*origin*/ );55 WEBCORE_EXPORT Ref<ArrayBuffer> buildClientDataJson(ClientDataType /*type*/, const BufferSource& challenge, const SecurityOrigin& /*origin*/, WebAuthn::Scope); 56 56 57 57 WEBCORE_EXPORT Vector<uint8_t> buildClientDataJsonHash(const ArrayBuffer& clientDataJson); -
trunk/Source/WebCore/html/FeaturePolicy.cpp
r283851 r286993 68 68 return "Magnetometer"; 69 69 #endif 70 #if ENABLE(WEB_AUTHN) 71 case FeaturePolicy::Type::PublickeyCredentialsGetRule: 72 return "PublickeyCredentialsGet"; 73 #endif 70 74 #if ENABLE(WEBXR) 71 75 case FeaturePolicy::Type::XRSpatialTracking: … … 185 189 bool isMagnetometerInitialized = false; 186 190 #endif 191 #if ENABLE(WEB_AUTHN) 192 bool isPublickeyCredentialsGetInitialized = false; 193 #endif 187 194 #if ENABLE(WEBXR) 188 195 bool isXRSpatialTrackingInitialized = false; … … 249 256 isMagnetometerInitialized = true; 250 257 updateList(document, policy.m_magnetometerRule, item.substring(13)); 258 continue; 259 } 260 #endif 261 #if ENABLE(WEB_AUTHN) 262 if (item.startsWith("publickey-credentials-get")) { 263 isPublickeyCredentialsGetInitialized = true; 264 updateList(document, policy.m_publickeyCredentialsGetRule, item.substring(26)); 251 265 continue; 252 266 } … … 283 297 if (!isMagnetometerInitialized) 284 298 policy.m_magnetometerRule.allowedList.add(document.securityOrigin().data()); 299 #endif 300 #if ENABLE(WEB_AUTHN) 301 if (!isPublickeyCredentialsGetInitialized) 302 policy.m_publickeyCredentialsGetRule.allowedList.add(document.securityOrigin().data()); 285 303 #endif 286 304 #if ENABLE(WEBXR) … … 339 357 return isAllowedByFeaturePolicy(m_magnetometerRule, origin); 340 358 #endif 359 #if ENABLE(WEB_AUTHN) 360 case Type::PublickeyCredentialsGetRule: 361 return isAllowedByFeaturePolicy(m_publickeyCredentialsGetRule, origin); 362 #endif 341 363 #if ENABLE(WEBXR) 342 364 case Type::XRSpatialTracking: -
trunk/Source/WebCore/html/FeaturePolicy.h
r282746 r286993 54 54 Magnetometer, 55 55 #endif 56 #if ENABLE(WEB_AUTHN) 57 PublickeyCredentialsGetRule, 58 #endif 56 59 #if ENABLE(WEBXR) 57 60 XRSpatialTracking, … … 82 85 AllowRule m_magnetometerRule; 83 86 #endif 87 #if ENABLE(WEB_AUTHN) 88 AllowRule m_publickeyCredentialsGetRule; 89 #endif 84 90 #if ENABLE(WEBXR) 85 91 AllowRule m_xrSpatialTrackingRule; -
trunk/Source/WebKit/ChangeLog
r286983 r286993 1 2021-12-13 J Pascoe <j_pascoe@apple.com> 2 3 [WebAuthn] Allow same-site, cross-origin iframe get() 4 https://bugs.webkit.org/show_bug.cgi?id=234180 5 rdar://85161142 6 7 Reviewed by Brent Fulgham. 8 9 The Web Authentication level 2 specifies a feature policy to allow get calls in 10 cross-origin i-frames. This patch implements this feature policy partially. Only 11 same-site, cross-origin i-frames are supported instead. This is for tracking prevention 12 purposes. https://w3c.github.io/webauthn/#sctn-iframe-guidance 13 14 This patch also starts passing ClientDataJSON hashes to ASC to avoid the situation 15 where WebKit includes crossOrigin or other fields in ClientDataJSON that ASC is 16 unaware of when generating ClientDataJSON. 17 18 Added layout test cases for same-site, cross-origin get calls. 19 20 * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h: 21 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm: 22 (produceClientDataJson): 23 * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: 24 (WebKit::configureRegistrationRequestContext): 25 (WebKit::configurationAssertionRequestContext): 26 (WebKit::WebAuthenticatorCoordinatorProxy::contextForRequest): 27 1 28 2021-12-13 Jean-Yves Avenard <jya@apple.com> 2 29 -
trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h
r284268 r286993 108 108 @interface ASCPublicKeyCredentialCreationOptions : NSObject <NSSecureCoding> 109 109 110 @property (nonatomic, copy) NSData *challenge; 110 @property (nonatomic, nullable, copy) NSData *challenge; 111 @property (nonatomic, nullable, copy) NSData *clientDataHash; 111 112 @property (nonatomic, copy) NSString *relyingPartyIdentifier; 112 113 @property (nonatomic, copy) NSString *userName; … … 117 118 @property (nonatomic) BOOL shouldRequireResidentKey; 118 119 120 @end 121 122 @interface ASCPublicKeyCredentialAssertionOptions : NSObject <NSSecureCoding> 123 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 124 @property (nonatomic, nullable, copy, readonly) NSData *challenge; 125 @property (nonatomic, nullable, copy) NSData *clientDataHash; 126 @property (nonatomic, nullable, readonly, copy) NSString *userVerificationPreference; 119 127 @end 120 128 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r286746 r286993 88 88 auto securityOrigin = WebCore::SecurityOrigin::createFromString(origin); 89 89 90 auto clientDataJson = buildClientDataJson(clientDataType, WebCore::BufferSource(challengeBuffer), securityOrigin );90 auto clientDataJson = buildClientDataJson(clientDataType, WebCore::BufferSource(challengeBuffer), securityOrigin, WebAuthn::Scope::SameOrigin); 91 91 return adoptNS([[NSData alloc] initWithBytes:clientDataJson->data() length:clientDataJson->byteLength()]); 92 92 } -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm
r285864 r286993 146 146 } 147 147 148 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options )148 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options, NSData *hash) 149 149 { 150 150 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration | ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration; … … 170 170 auto credentialCreationOptions = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]); 171 171 172 [credentialCreationOptions setChallenge:WebCore::toNSData(options.challenge).get()]; 172 if ([credentialCreationOptions respondsToSelector:@selector(setClientDataHash:)]) 173 [credentialCreationOptions setClientDataHash:toNSData(hash).get()]; 174 else 175 [credentialCreationOptions setChallenge:WebCore::toNSData(options.challenge).get()]; 173 176 [credentialCreationOptions setRelyingPartyIdentifier:options.rp.id]; 174 177 [credentialCreationOptions setUserName:options.user.name]; … … 203 206 } 204 207 205 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options )208 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options, Vector<uint_8> hash) 206 209 { 207 210 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyAssertion | ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion; … … 228 231 [requestContext setRelyingPartyIdentifier:options.rpId]; 229 232 230 auto challenge = WebCore::toNSData(options.challenge); 231 232 if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion) 233 [requestContext setPlatformKeyCredentialAssertionOptions:[allocASCPublicKeyCredentialAssertionOptionsInstance() initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]]; 234 235 if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion) 236 [requestContext setSecurityKeyCredentialAssertionOptions:[allocASCPublicKeyCredentialAssertionOptionsInstance() initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]]; 233 if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion) { 234 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 235 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 236 auto nsHash = toNSData(hash); 237 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId clientDataHash:nsHash userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()] 238 } else { 239 auto challenge = WebCore::toNSData(options.challenge); 240 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()] 241 } 242 243 [requestContext setPlatformKeyCredentialAssertionOptions:assertionOptions.get()]; 244 } 245 246 if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion) { 247 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 248 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 249 auto nsHash = toNSData(hash); 250 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId clientDataHash:nsHash userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]]; 251 } else { 252 auto challenge = WebCore::toNSData(options.challenge); 253 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]]; 254 } 255 [requestContext setSecurityKeyCredentialAssertionOptions:assertionOptions.get()]; 256 } 237 257 238 258 return requestContext; … … 243 263 RetainPtr<ASCCredentialRequestContext> result; 244 264 WTF::switchOn(requestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 245 result = configureRegistrationRequestContext(options );265 result = configureRegistrationRequestContext(options, requestData.hash); 246 266 }, [&](const PublicKeyCredentialRequestOptions& options) { 247 result = configurationAssertionRequestContext(options );267 result = configurationAssertionRequestContext(options, requestData.hash); 248 268 }); 249 269 return result;
Note: See TracChangeset
for help on using the changeset viewer.