Changeset 287116 in webkit
- Timestamp:
- Dec 15, 2021, 4:52:57 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r287102 r287116 1 2021-12-15 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=234309 5 rdar://problem/86486313 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-15 Ryan Haddad <ryanhaddad@apple.com> 2 17 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287110 r287116 1 2021-12-15 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=234309 5 rdar://problem/86486313 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-15 Brent Fulgham <bfulgham@apple.com> 2 34 -
trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
r287002 r287116 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; 54 53 54 bool isSameOrigin = true; 55 bool isSameSite = true; 55 56 auto& origin = m_document->securityOrigin(); 57 auto& url = m_document->url(); 56 58 for (auto* document = m_document->parentDocument(); document; document = document->parentDocument()) { 59 if (!origin.isSameOriginDomain(document->securityOrigin()) && !areRegistrableDomainsEqual(url, document->url())) 60 isSameSite = false; 57 61 if (!origin.isSameOriginAs(document->securityOrigin())) 58 returnfalse;62 isSameOrigin = false; 59 63 } 60 return true; 64 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287002 r287116 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
r287106 r287116 1 2021-12-15 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=234309 5 rdar://problem/86486313 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-15 Alex Christensen <achristensen@webkit.org> 2 29 -
trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h
r287002 r287116 26 26 #pragma once 27 27 28 #if HAVE(UNIFIED_ASC_AUTH_UI) 29 #import <AuthenticationServicesCore/AuthenticationServicesCore.h> 30 #import <AuthenticationServicesCore/AuthenticationServicesCorePrivate.h> 31 #elif HAVE(ASC_AUTH_UI) 28 #if HAVE(ASC_AUTH_UI) || HAVE(UNIFIED_ASC_AUTH_UI) 32 29 33 30 NS_ASSUME_NONNULL_BEGIN … … 72 69 @end 73 70 71 @interface ASCAuthorizationRemotePresenter : NSObject 72 73 #if TARGET_OS_OSX 74 - (void)presentWithWindow:(NSWindow *)window daemonEndpoint:(NSXPCListenerEndpoint *)daemonEndpoint completionHandler:(void (^)(id <ASCCredentialProtocol>, NSError *))completionHandler; 75 #endif 76 77 @end 78 74 79 @class ASCCredentialRequestContext; 75 80 … … 106 111 }; 107 112 113 @class ASCPublicKeyCredentialDescriptor; 114 115 @interface ASCPublicKeyCredentialDescriptor : NSObject <NSSecureCoding> 116 117 - (instancetype)initWithCredentialID:(NSData *)credentialID transports:(nullable NSArray<NSString *> *)allowedTransports; 118 119 @property (nonatomic, readonly) NSData *credentialID; 120 @property (nonatomic, nullable, readonly) NSArray<NSString *> *transports; 121 122 @end 123 124 @class ASCPublicKeyCredentialDescriptor; 125 126 typedef NS_ENUM(NSUInteger, ASCPublicKeyCredentialKind) { 127 ASCPublicKeyCredentialKindPlatform = 1, 128 ASCPublicKeyCredentialKindSecurityKey, 129 }; 130 131 @interface ASCPublicKeyCredentialAssertionOptions : NSObject <NSSecureCoding> 132 133 - (instancetype)initWithKind:(ASCPublicKeyCredentialKind)credentialKind relyingPartyIdentifier:(NSString *)relyingPartyIdentifier challenge:(NSData *)challenge userVerificationPreference:(nullable NSString *)userVerificationPreference allowedCredentials:(nullable NSArray<ASCPublicKeyCredentialDescriptor *> *)allowedCredentials; 134 135 - (instancetype)initWithKind:(ASCPublicKeyCredentialKind)credentialKind relyingPartyIdentifier:(NSString *)relyingPartyIdentifier clientDataHash:(NSData *)clientDataHash userVerificationPreference:(nullable NSString *)userVerificationPreference allowedCredentials:(nullable NSArray<ASCPublicKeyCredentialDescriptor *> *)allowedCredentials; 136 137 @property (nonatomic, readonly) ASCPublicKeyCredentialKind credentialKind; 138 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 139 @property (nonatomic, nullable, copy, readonly) NSData *challenge; 140 // If clientDataHash is null, then gets generated from challenge and relyingPartyIdentifier. 141 @property (nonatomic, nullable, copy) NSData *clientDataHash; 142 @property (nonatomic, nullable, readonly, copy) NSString *userVerificationPreference; 143 144 @property (nonatomic, nullable, readonly, copy) NSArray<ASCPublicKeyCredentialDescriptor *> *allowedCredentials; 145 146 @end 147 148 149 typedef NS_OPTIONS(NSUInteger, ASCCredentialRequestTypes) { 150 ASCCredentialRequestTypeNone = 0, 151 ASCCredentialRequestTypePassword = 1 << 0, 152 ASCCredentialRequestTypeAppleID = 1 << 1, 153 ASCCredentialRequestTypePlatformPublicKeyRegistration = 1 << 2, 154 ASCCredentialRequestTypePlatformPublicKeyAssertion = 1 << 3, 155 ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration = 1 << 4, 156 ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion = 1 << 5, 157 }; 158 108 159 @interface ASCPublicKeyCredentialCreationOptions : NSObject <NSSecureCoding> 109 160 110 @property (nonatomic, copy) NSData *challenge; 161 @property (nonatomic, nullable, copy) NSData *challenge; 162 @property (nonatomic, nullable, copy) NSData *clientDataHash; 111 163 @property (nonatomic, copy) NSString *relyingPartyIdentifier; 112 164 @property (nonatomic, copy) NSString *userName; … … 114 166 @property (nonatomic, copy) NSString *userDisplayName; 115 167 @property (nonatomic, copy) NSArray<NSNumber *> *supportedAlgorithmIdentifiers; 168 @property (nonatomic, nullable, copy) NSString *userVerificationPreference; 116 169 117 170 @property (nonatomic) BOOL shouldRequireResidentKey; 171 @property (nonatomic, copy) NSArray<ASCPublicKeyCredentialDescriptor *> *excludedCredentials; 118 172 119 173 @end … … 150 204 @end 151 205 206 @interface ASCCredentialRequestContext : NSObject <NSSecureCoding> 207 208 - (instancetype)init NS_UNAVAILABLE; 209 + (instancetype)new NS_UNAVAILABLE; 210 211 - (instancetype)initWithRequestTypes:(ASCCredentialRequestTypes)requestTypes; 212 213 @property (nonatomic, readonly) NSUInteger requestTypes; 214 @property (nonatomic, nullable, copy) NSString *relyingPartyIdentifier; 215 216 @property (nonatomic, nullable, copy) ASCPublicKeyCredentialCreationOptions *platformKeyCredentialCreationOptions; 217 @property (nonatomic, nullable, copy) ASCPublicKeyCredentialCreationOptions *securityKeyCredentialCreationOptions; 218 219 @property (nonatomic, nullable, copy) ASCPublicKeyCredentialAssertionOptions *platformKeyCredentialAssertionOptions; 220 @property (nonatomic, nullable, copy) ASCPublicKeyCredentialAssertionOptions *securityKeyCredentialAssertionOptions; 221 222 @end 223 152 224 @protocol ASCCredentialProtocol <NSObject, NSSecureCoding> 225 226 @end 227 228 @class _WKAuthenticatorAttestationResponse; 229 230 @interface ASCPlatformPublicKeyCredentialRegistration : NSObject <ASCCredentialProtocol> 231 232 - (instancetype)initWithRelyingPartyIdentifier:(NSString *)relyingPartyIdentifier attestationObject:(NSData *)attestationObject rawClientDataJSON:(NSData *)rawClientDataJSON credentialID:(NSData *)credentialID; 233 234 - (instancetype)initWithRelyingPartyIdentifier:(NSString *)relyingPartyIdentifier authenticatorAttestationResponse:(_WKAuthenticatorAttestationResponse *)attestationResponse rawClientDataJSON:(NSData *)rawClientDataJSON; 235 236 @property (nonatomic, copy, readonly) NSData *credentialID; 237 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 238 @property (nonatomic, copy, readonly) NSData *attestationObject; 239 @property (nonatomic, copy, readonly) NSData *rawClientDataJSON; 240 241 + (instancetype)new NS_UNAVAILABLE; 242 - (instancetype)init NS_UNAVAILABLE; 243 244 @end 245 246 @interface ASCSecurityKeyPublicKeyCredentialRegistration : NSObject <ASCCredentialProtocol> 247 248 - (instancetype)initWithRelyingPartyIdentifier:(NSString *)relyingPartyIdentifier authenticatorAttestationResponse:(_WKAuthenticatorAttestationResponse *)attestationResponse; 249 250 @property (nonatomic, copy, readonly) NSData *credentialID; 251 @property (nonatomic, copy, readonly) NSData *rawClientDataJSON; 252 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 253 @property (nonatomic, copy, readonly) NSData *attestationObject; 254 255 @end 256 257 @class _WKAuthenticatorAssertionResponse; 258 259 @interface ASCPlatformPublicKeyCredentialAssertion : NSObject <ASCCredentialProtocol> 260 261 - (instancetype)initWithRelyingPartyIdentifier:(NSString *)relyingPartyIdentifier authenticatorAssertionResponse:(_WKAuthenticatorAssertionResponse *)assertionResponse; 262 263 @property (nonatomic, copy, readonly) NSData *credentialID; 264 @property (nonatomic, copy, readonly) NSData *rawClientDataJSON; 265 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 266 @property (nonatomic, copy, readonly) NSData *authenticatorData; 267 @property (nonatomic, copy, readonly) NSData *signature; 268 @property (nonatomic, copy, readonly, nullable) NSData *userHandle; 269 270 @end 271 272 @interface ASCSecurityKeyPublicKeyCredentialAssertion : NSObject <ASCCredentialProtocol> 273 274 - (instancetype)initWithRelyingPartyIdentifier:(NSString *)relyingPartyIdentifier authenticatorAssertionResponse:(_WKAuthenticatorAssertionResponse *)assertionResponse; 275 276 @property (nonatomic, copy, readonly) NSData *credentialID; 277 @property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier; 278 @property (nonatomic, copy, readonly) NSData *authenticatorData; 279 @property (nonatomic, copy, readonly) NSData *signature; 280 @property (nonatomic, copy, readonly, nullable) NSData *userHandle; 281 @property (nonatomic, copy, readonly) NSData *rawClientDataJSON; 282 283 @end 284 285 @protocol ASCAgentProtocol <NSObject> 286 287 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST 288 - (void)performAuthorizationRequestsForContext:(ASCCredentialRequestContext *)context withCompletionHandler:(void (^)(id <ASCCredentialProtocol> _Nullable credential, NSError * _Nullable error))completionHandler; 289 #elif TARGET_OS_OSX || TARGET_OS_MACCATALYST 290 - (void)performAuthorizationRequestsForContext:(ASCCredentialRequestContext *)context withClearanceHandler:(void (^)(NSXPCListenerEndpoint * _Nullable daemonEndpoint, NSError * _Nullable error))clearanceHandler; 291 292 - (void)beginAuthorizationForApplicationIdentifier:(NSString *)applicationIdentifier fromEndpoint:(NSXPCListenerEndpoint *)listenerEndpoint; 293 294 - (void)userSelectedLoginChoice:(id <ASCLoginChoiceProtocol>)loginChoice authenticatedContext:(LAContext *)context completionHandler:(void (^)(id <ASCCredentialProtocol> _Nullable, NSError * _Nullable))completionHandler; 295 296 - (void)requestCompletedWithCredential:(nullable id<ASCCredentialProtocol>)credential error:(nullable NSError *)error; 297 #endif 298 299 @end 300 301 @interface ASCAgentProxy : NSObject <ASCAgentProtocol> 302 303 - (instancetype)init; 304 305 #if TARGET_OS_OSX 306 - (instancetype)initWithEndpoint:(NSXPCListenerEndpoint *)endpoint; 307 #endif 308 309 - (void)invalidate; 310 311 - (void)reconnectIfNecessary; 153 312 154 313 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r287002 r287116 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
r287002 r287116 49 49 { 50 50 return ArrayBuffer::create(reinterpret_cast<const uint8_t*>(data.bytes), data.length); 51 } 52 53 static inline RetainPtr<NSData> toNSData(const Vector<uint8_t>& data) 54 { 55 return adoptNS([[NSData alloc] initWithBytes:data.data() length:data.size()]); 51 56 } 52 57 … … 146 151 } 147 152 148 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options )153 static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options, Vector<uint8_t> hash) 149 154 { 150 155 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration | ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration; … … 170 175 auto credentialCreationOptions = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]); 171 176 172 [credentialCreationOptions setChallenge:WebCore::toNSData(options.challenge).get()]; 177 if ([credentialCreationOptions respondsToSelector:@selector(setClientDataHash:)]) 178 [credentialCreationOptions setClientDataHash:toNSData(hash).get()]; 179 else 180 [credentialCreationOptions setChallenge:WebCore::toNSData(options.challenge).get()]; 173 181 [credentialCreationOptions setRelyingPartyIdentifier:options.rp.id]; 174 182 [credentialCreationOptions setUserName:options.user.name]; … … 203 211 } 204 212 205 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options )213 static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options, Vector<uint8_t> hash) 206 214 { 207 215 ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyAssertion | ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion; … … 228 236 [requestContext setRelyingPartyIdentifier:options.rpId]; 229 237 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()]]; 238 if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion) { 239 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 240 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 241 auto nsHash = toNSData(hash); 242 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId clientDataHash:nsHash.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 243 } else { 244 auto challenge = WebCore::toNSData(options.challenge); 245 [assertionOptions initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 246 } 247 248 [requestContext setPlatformKeyCredentialAssertionOptions:assertionOptions.get()]; 249 } 250 251 if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion) { 252 auto assertionOptions = adoptNS(allocASCPublicKeyCredentialAssertionOptionsInstance()); 253 if ([assertionOptions respondsToSelector:@selector(initWithKind:relyingPartyIdentifier:clientDataHash:userVerificationPreference:allowedCredentials:)]) { 254 auto nsHash = toNSData(hash); 255 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId clientDataHash:nsHash.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 256 } else { 257 auto challenge = WebCore::toNSData(options.challenge); 258 [assertionOptions initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]; 259 } 260 [requestContext setSecurityKeyCredentialAssertionOptions:assertionOptions.get()]; 261 } 237 262 238 263 return requestContext; … … 243 268 RetainPtr<ASCCredentialRequestContext> result; 244 269 WTF::switchOn(requestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 245 result = configureRegistrationRequestContext(options );270 result = configureRegistrationRequestContext(options, requestData.hash); 246 271 }, [&](const PublicKeyCredentialRequestOptions& options) { 247 result = configurationAssertionRequestContext(options );272 result = configurationAssertionRequestContext(options, requestData.hash); 248 273 }); 249 274 return result;
Note:
See TracChangeset
for help on using the changeset viewer.