Changeset 253398 in webkit
- Timestamp:
- Dec 11, 2019 3:19:08 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 33 edited
- 4 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r253153 r253398 462 462 Modules/webauthn/AttestationConveyancePreference.idl 463 463 Modules/webauthn/AuthenticationExtensionsClientInputs.idl 464 Modules/webauthn/AuthenticationExtensionsClientOutputs.idl 464 465 Modules/webauthn/AuthenticatorAssertionResponse.idl 465 466 Modules/webauthn/AuthenticatorAttestationResponse.idl -
trunk/Source/WebCore/ChangeLog
r253397 r253398 1 2019-12-11 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData 4 https://bugs.webkit.org/show_bug.cgi?id=190783 5 <rdar://problem/57781183> 6 7 Reviewed by Brent Fulgham. 8 9 This patch combines AuthenticatorResponse and PublicKeyCredentialData, and therefore renames 10 PublicKeyCredentialData to AuthenticatorResponseData as well. The complexity of WebKit's CTAP 11 implementation has reached the point that PublicKeyCredentialData is not appropriate to represent 12 all the different type of responses from authenticators anymore. For example, authenticatorGetNextAssertion 13 depends on the numberOfCredentials member from authenticatorGetAssertion response to function, but 14 numberOfCredentials is not used anywhere else. Therefore, a polymorphic type is needed to 15 represent different responses from authenticators instead of an uniform one, i.e., PublicKeyCredentialData. 16 17 AuthenticatorResponse seems to be the best fit. However, there are some limitations: 18 1) it is a WebIDL interface, and therefore is RefCounted. RefCounted objects cannot be serialized through 19 IPC. To solve this, AuthenticatorResponseData (PublicKeyCredentialData) is kept as an intermediate type 20 that is only used during IPC. 21 2) it doesn't contain all the information from an actual authenticator response. To solve this, it 22 has been enlarged to include all members from PublicKeyCredential. After this patch, PublicKeyCredential 23 will be a thin wrapper on top of AuthenticatorResponse. 24 25 Covered by existing tests. 26 27 * CMakeLists.txt: 28 * DerivedSources-input.xcfilelist: 29 * DerivedSources-output.xcfilelist: 30 * DerivedSources.make: 31 * Headers.cmake: 32 * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl. 33 * Modules/webauthn/AuthenticationExtensionsClientOutputs.idl: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl. 34 This is separated from PublicKeyCredential such that AuthenticatorResponse can include it. 35 * Modules/webauthn/AuthenticatorAssertionResponse.cpp: Added. 36 (WebCore::AuthenticatorAssertionResponse::create): 37 (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse): 38 (WebCore::AuthenticatorAssertionResponse::data const): 39 * Modules/webauthn/AuthenticatorAssertionResponse.h: 40 (WebCore::AuthenticatorAssertionResponse::create): Deleted. 41 (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse): Deleted. 42 * Modules/webauthn/AuthenticatorAttestationResponse.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h. 43 (WebCore::AuthenticatorAttestationResponse::create): 44 (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse): 45 (WebCore::AuthenticatorAttestationResponse::data const): 46 * Modules/webauthn/AuthenticatorAttestationResponse.h: 47 (WebCore::AuthenticatorAttestationResponse::create): Deleted. 48 (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse): Deleted. 49 * Modules/webauthn/AuthenticatorCoordinator.cpp: 50 (WebCore::AuthenticatorCoordinator::create const): 51 (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const): 52 * Modules/webauthn/AuthenticatorCoordinatorClient.h: 53 * Modules/webauthn/AuthenticatorResponse.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp. 54 (WebCore::AuthenticatorResponse::tryCreate): 55 (WebCore::AuthenticatorResponse::data const): 56 (WebCore::AuthenticatorResponse::extensions const): 57 (WebCore::AuthenticatorResponse::setClientDataJSON): 58 (WebCore::AuthenticatorResponse::clientDataJSON const): 59 (WebCore::AuthenticatorResponse::AuthenticatorResponse): 60 * Modules/webauthn/AuthenticatorResponse.h: 61 (WebCore::AuthenticatorResponse::rawId const): 62 (WebCore::AuthenticatorResponse::setExtensions): 63 (WebCore::AuthenticatorResponse::AuthenticatorResponse): Deleted. 64 (WebCore::AuthenticatorResponse::clientDataJSON const): Deleted. 65 * Modules/webauthn/AuthenticatorResponseData.h: Renamed from Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h. 66 (WebCore::AuthenticatorResponseData::encode const): 67 (WebCore::AuthenticatorResponseData::decode): 68 * Modules/webauthn/PublicKeyCredential.cpp: 69 (WebCore::PublicKeyCredential::create): 70 (WebCore::PublicKeyCredential::rawId const): 71 (WebCore::PublicKeyCredential::getClientExtensionResults const): 72 (WebCore::PublicKeyCredential::PublicKeyCredential): 73 (WebCore::PublicKeyCredential::tryCreate): Deleted. 74 * Modules/webauthn/PublicKeyCredential.h: 75 * Modules/webauthn/PublicKeyCredential.idl: 76 * Modules/webauthn/fido/DeviceResponseConverter.cpp: 77 (fido::readCTAPMakeCredentialResponse): 78 (fido::readCTAPGetAssertionResponse): 79 * Modules/webauthn/fido/DeviceResponseConverter.h: 80 A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData. 81 * Modules/webauthn/fido/U2fResponseConverter.cpp: 82 (fido::readU2fRegisterResponse): 83 (fido::readU2fSignResponse): 84 * Modules/webauthn/fido/U2fResponseConverter.h: 85 A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData. 86 * Sources.txt: 87 * WebCore.xcodeproj/project.pbxproj: 88 1 89 2019-12-11 Eric Carlson <eric.carlson@apple.com> 2 90 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r253153 r253398 315 315 $(PROJECT_DIR)/Modules/webauthn/AttestationConveyancePreference.idl 316 316 $(PROJECT_DIR)/Modules/webauthn/AuthenticationExtensionsClientInputs.idl 317 $(PROJECT_DIR)/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl 317 318 $(PROJECT_DIR)/Modules/webauthn/AuthenticatorAssertionResponse.idl 318 319 $(PROJECT_DIR)/Modules/webauthn/AuthenticatorAttestationResponse.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r253153 r253398 161 161 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientInputs.cpp 162 162 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientInputs.h 163 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientOutputs.cpp 164 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientOutputs.h 163 165 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorAssertionResponse.cpp 164 166 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorAssertionResponse.h -
trunk/Source/WebCore/DerivedSources.make
r253153 r253398 374 374 $(WebCore)/Modules/webauthn/AttestationConveyancePreference.idl \ 375 375 $(WebCore)/Modules/webauthn/AuthenticationExtensionsClientInputs.idl \ 376 $(WebCore)/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl \ 376 377 $(WebCore)/Modules/webauthn/AuthenticatorAssertionResponse.idl \ 377 378 $(WebCore)/Modules/webauthn/AuthenticatorAttestationResponse.idl \ -
trunk/Source/WebCore/Headers.cmake
r253380 r253398 113 113 Modules/webauthn/AttestationConveyancePreference.h 114 114 Modules/webauthn/AuthenticationExtensionsClientInputs.h 115 Modules/webauthn/AuthenticationExtensionsClientOutputs.h 115 116 Modules/webauthn/AuthenticatorCoordinator.h 116 117 Modules/webauthn/AuthenticatorCoordinatorClient.h 118 Modules/webauthn/AuthenticatorResponseData.h 117 119 Modules/webauthn/AuthenticatorTransport.h 118 120 Modules/webauthn/PublicKeyCredentialCreationOptions.h 119 Modules/webauthn/PublicKeyCredentialData.h120 121 Modules/webauthn/PublicKeyCredentialDescriptor.h 121 122 Modules/webauthn/PublicKeyCredentialRequestOptions.h -
trunk/Source/WebCore/Modules/webauthn/AuthenticationExtensionsClientOutputs.h
r253397 r253398 1 1 /* 2 * Copyright (C) 201 7Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 [ 27 Conditional=WEB_AUTHN, 28 EnabledAtRuntime=WebAuthentication, 29 Exposed=Window, 30 SecureContext, 31 ] interface PublicKeyCredential : BasicCredential { 32 [SameObject] readonly attribute ArrayBuffer rawId; 33 [SameObject] readonly attribute AuthenticatorResponse response; 34 AuthenticationExtensionsClientOutputs getClientExtensionResults(); 26 #pragma once 35 27 36 [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable(); 28 #if ENABLE(WEB_AUTHN) 29 30 namespace WebCore { 31 32 struct AuthenticationExtensionsClientOutputs { 33 Optional<bool> appid; 37 34 }; 38 35 39 [ 40 Conditional=WEB_AUTHN, 41 JSGenerateToJSObject, 42 ] dictionary AuthenticationExtensionsClientOutputs { 43 boolean appid; 44 }; 36 } // namespace WebCore 37 38 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebCore/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl
r253397 r253398 1 1 /* 2 * Copyright (C) 201 7Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 [ 27 27 Conditional=WEB_AUTHN, 28 EnabledAtRuntime=WebAuthentication,29 Exposed=Window,30 SecureContext,31 ] interface PublicKeyCredential : BasicCredential {32 [SameObject] readonly attribute ArrayBuffer rawId;33 [SameObject] readonly attribute AuthenticatorResponse response;34 AuthenticationExtensionsClientOutputs getClientExtensionResults();35 36 [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();37 };38 39 [40 Conditional=WEB_AUTHN,41 28 JSGenerateToJSObject, 42 29 ] dictionary AuthenticationExtensionsClientOutputs { -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h
r238238 r253398 34 34 class AuthenticatorAssertionResponse : public AuthenticatorResponse { 35 35 public: 36 static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle) 37 { 38 return adoptRef(*new AuthenticatorAssertionResponse(WTFMove(clientDataJSON), WTFMove(authenticatorData), WTFMove(signature), WTFMove(userHandle))); 39 } 40 36 static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle, Optional<AuthenticationExtensionsClientOutputs>&&); 37 WEBCORE_EXPORT static Ref<AuthenticatorAssertionResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle); 41 38 virtual ~AuthenticatorAssertionResponse() = default; 42 39 … … 46 43 47 44 private: 48 AuthenticatorAssertionResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle) 49 : AuthenticatorResponse(WTFMove(clientDataJSON)) 50 , m_authenticatorData(WTFMove(authenticatorData)) 51 , m_signature(WTFMove(signature)) 52 , m_userHandle(WTFMove(userHandle)) 53 { 54 } 45 AuthenticatorAssertionResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, RefPtr<ArrayBuffer>&&); 55 46 56 47 Type type() const final { return Type::Assertion; } 48 AuthenticatorResponseData data() const final; 57 49 58 50 Ref<ArrayBuffer> m_authenticatorData; -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp
r253397 r253398 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "AuthenticatorAttestationResponse.h" 27 28 28 29 #if ENABLE(WEB_AUTHN) 29 30 30 #include "AuthenticatorResponse .h"31 #include "AuthenticatorResponseData.h" 31 32 32 33 namespace WebCore { 33 34 34 class AuthenticatorAttestationResponse : public AuthenticatorResponse { 35 public: 36 static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject) 37 { 38 return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject))); 39 } 35 Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject) 36 { 37 return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(rawId), WTFMove(attestationObject))); 38 } 40 39 41 virtual ~AuthenticatorAttestationResponse() = default; 40 Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject) 41 { 42 return create(ArrayBuffer::create(rawId.data(), rawId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size())); 43 } 42 44 43 ArrayBuffer* attestationObject() const { return m_attestationObject.ptr(); } 45 AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject) 46 : AuthenticatorResponse(WTFMove(rawId)) 47 , m_attestationObject(WTFMove(attestationObject)) 48 { 49 } 44 50 45 private: 46 AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject) 47 : AuthenticatorResponse(WTFMove(clientDataJSON)) 48 , m_attestationObject(WTFMove(attestationObject)) 49 { 50 } 51 52 Type type() const final { return Type::Attestation; } 53 54 Ref<ArrayBuffer> m_attestationObject; 55 }; 51 AuthenticatorResponseData AuthenticatorAttestationResponse::data() const 52 { 53 auto data = AuthenticatorResponse::data(); 54 data.isAuthenticatorAttestationResponse = true; 55 data.attestationObject = m_attestationObject.copyRef(); 56 return data; 57 } 56 58 57 59 } // namespace WebCore 58 60 59 SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(AuthenticatorAttestationResponse, AuthenticatorResponse::Type::Attestation)60 61 61 #endif // ENABLE(WEB_AUTHN) -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h
r235888 r253398 34 34 class AuthenticatorAttestationResponse : public AuthenticatorResponse { 35 35 public: 36 static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject) 37 { 38 return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject))); 39 } 36 static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject); 37 WEBCORE_EXPORT static Ref<AuthenticatorAttestationResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject); 40 38 41 39 virtual ~AuthenticatorAttestationResponse() = default; … … 44 42 45 43 private: 46 AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject) 47 : AuthenticatorResponse(WTFMove(clientDataJSON)) 48 , m_attestationObject(WTFMove(attestationObject)) 49 { 50 } 44 AuthenticatorAttestationResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&); 51 45 52 46 Type type() const final { return Type::Attestation; } 47 AuthenticatorResponseData data() const final; 53 48 54 49 Ref<ArrayBuffer> m_attestationObject; -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
r251762 r253398 33 33 #include "AuthenticatorAttestationResponse.h" 34 34 #include "AuthenticatorCoordinatorClient.h" 35 #include "AuthenticatorResponseData.h" 35 36 #include "Document.h" 36 37 #include "JSBasicCredential.h" … … 38 39 #include "PublicKeyCredential.h" 39 40 #include "PublicKeyCredentialCreationOptions.h" 40 #include "PublicKeyCredentialData.h"41 41 #include "PublicKeyCredentialRequestOptions.h" 42 42 #include "RegistrableDomain.h" … … 186 186 } 187 187 188 auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] ( PublicKeyCredentialData&& data, ExceptionData&& exception) mutable {188 auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (AuthenticatorResponseData&& data, ExceptionData&& exception) mutable { 189 189 if (abortSignal && abortSignal->aborted()) { 190 190 promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s }); … … 192 192 } 193 193 194 data.clientDataJSON = WTFMove(clientDataJson);195 if (auto publicKeyCredential = PublicKeyCredential::tryCreate(WTFMove(data))) {196 promise.resolve( publicKeyCredential.get());194 if (auto response = AuthenticatorResponse::tryCreate(WTFMove(data))) { 195 response->setClientDataJSON(WTFMove(clientDataJson)); 196 promise.resolve(PublicKeyCredential::create(response.releaseNonNull()).ptr()); 197 197 return; 198 198 } … … 257 257 } 258 258 259 auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] ( PublicKeyCredentialData&& data, ExceptionData&& exception) mutable {259 auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (AuthenticatorResponseData&& data, ExceptionData&& exception) mutable { 260 260 if (abortSignal && abortSignal->aborted()) { 261 261 promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s }); … … 263 263 } 264 264 265 data.clientDataJSON = WTFMove(clientDataJson);266 if (auto publicKeyCredential = PublicKeyCredential::tryCreate(WTFMove(data))) {267 promise.resolve( publicKeyCredential.get());265 if (auto response = AuthenticatorResponse::tryCreate(WTFMove(data))) { 266 response->setClientDataJSON(WTFMove(clientDataJson)); 267 promise.resolve(PublicKeyCredential::create(response.releaseNonNull()).ptr()); 268 268 return; 269 269 } -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h
r251489 r253398 39 39 class SecurityOrigin; 40 40 41 struct AuthenticatorResponseData; 41 42 struct PublicKeyCredentialCreationOptions; 42 struct PublicKeyCredentialData;43 43 struct PublicKeyCredentialRequestOptions; 44 44 45 using RequestCompletionHandler = CompletionHandler<void(WebCore:: PublicKeyCredentialData&&, WebCore::ExceptionData&&)>;45 using RequestCompletionHandler = CompletionHandler<void(WebCore::AuthenticatorResponseData&&, WebCore::ExceptionData&&)>; 46 46 using QueryCompletionHandler = CompletionHandler<void(bool)>; 47 47 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp
r253397 r253398 1 1 /* 2 * Copyright (C) 201 7Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include " PublicKeyCredential.h"27 #include "AuthenticatorResponse.h" 28 28 29 29 #if ENABLE(WEB_AUTHN) … … 31 31 #include "AuthenticatorAssertionResponse.h" 32 32 #include "AuthenticatorAttestationResponse.h" 33 #include "AuthenticatorCoordinator.h" 34 #include "AuthenticatorResponse.h" 35 #include "Document.h" 36 #include "JSDOMPromiseDeferred.h" 37 #include "Page.h" 38 #include "PublicKeyCredentialData.h" 39 #include "RuntimeEnabledFeatures.h" 40 #include <wtf/text/Base64.h> 33 #include "AuthenticatorResponseData.h" 41 34 42 35 namespace WebCore { 43 36 44 RefPtr< PublicKeyCredential> PublicKeyCredential::tryCreate(PublicKeyCredentialData&& data)37 RefPtr<AuthenticatorResponse> AuthenticatorResponse::tryCreate(AuthenticatorResponseData&& data) 45 38 { 46 if (!data.rawId || !data.clientDataJSON)39 if (!data.rawId) 47 40 return nullptr; 48 41 … … 51 44 return nullptr; 52 45 53 return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull()), { data.appid }));46 return AuthenticatorAttestationResponse::create(data.rawId.releaseNonNull(), data.attestationObject.releaseNonNull()); 54 47 } 55 48 … … 57 50 return nullptr; 58 51 59 return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle)), { data.appid }));52 return AuthenticatorAssertionResponse::create(data.rawId.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle), AuthenticationExtensionsClientOutputs { data.appid }); 60 53 } 61 54 62 PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response, AuthenticationExtensionsClientOutputs&& extensions) 63 : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote) 64 , m_rawId(WTFMove(id)) 65 , m_response(WTFMove(response)) 66 , m_extensions(WTFMove(extensions)) 55 AuthenticatorResponseData AuthenticatorResponse::data() const 67 56 { 57 AuthenticatorResponseData data; 58 data.rawId = m_rawId.copyRef(); 59 data.appid = m_extensions.appid; 60 return data; 68 61 } 69 62 70 PublicKeyCredential::AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const 63 ArrayBuffer* AuthenticatorResponse::rawId() const 64 { 65 return m_rawId.ptr(); 66 } 67 68 void AuthenticatorResponse::setExtensions(AuthenticationExtensionsClientOutputs&& extensions) 69 { 70 m_extensions = WTFMove(extensions); 71 } 72 73 AuthenticationExtensionsClientOutputs AuthenticatorResponse::extensions() const 71 74 { 72 75 return m_extensions; 73 76 } 74 77 75 void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document& document, DOMPromiseDeferred<IDLBoolean>&& promise)78 void AuthenticatorResponse::setClientDataJSON(Ref<ArrayBuffer>&& clientDataJSON) 76 79 { 77 if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationLocalAuthenticatorEnabled()) { 78 promise.resolve(false); 79 return; 80 } 81 document.page()->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise)); 80 m_clientDataJSON = WTFMove(clientDataJSON); 81 } 82 83 ArrayBuffer* AuthenticatorResponse::clientDataJSON() const 84 { 85 return m_clientDataJSON.get(); 86 } 87 88 AuthenticatorResponse::AuthenticatorResponse(Ref<ArrayBuffer>&& rawId) 89 : m_rawId(WTFMove(rawId)) 90 { 82 91 } 83 92 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h
r235888 r253398 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include <JavaScriptCore/ArrayBuffer.h> 30 #include "AuthenticationExtensionsClientOutputs.h" 31 #include "IDLTypes.h" 31 32 #include <wtf/RefCounted.h> 32 33 #include <wtf/TypeCasts.h> 33 34 34 35 namespace WebCore { 36 37 struct AuthenticatorResponseData; 35 38 36 39 class AuthenticatorResponse : public RefCounted<AuthenticatorResponse> { … … 41 44 }; 42 45 43 explicit AuthenticatorResponse(Ref<ArrayBuffer>&& clientDataJSON) 44 : m_clientDataJSON(WTFMove(clientDataJSON)) 45 { 46 } 46 static RefPtr<AuthenticatorResponse> tryCreate(AuthenticatorResponseData&&); 47 47 virtual ~AuthenticatorResponse() = default; 48 48 49 49 virtual Type type() const = 0; 50 virtual AuthenticatorResponseData data() const; 50 51 51 ArrayBuffer* clientDataJSON() const { return m_clientDataJSON.ptr(); } 52 WEBCORE_EXPORT ArrayBuffer* rawId() const; 53 WEBCORE_EXPORT void setExtensions(AuthenticationExtensionsClientOutputs&&); 54 AuthenticationExtensionsClientOutputs extensions() const; 55 void setClientDataJSON(Ref<ArrayBuffer>&&); 56 ArrayBuffer* clientDataJSON() const; 57 58 protected: 59 AuthenticatorResponse(Ref<ArrayBuffer>&&); 52 60 53 61 private: 54 Ref<ArrayBuffer> m_clientDataJSON; 62 Ref<ArrayBuffer> m_rawId; 63 AuthenticationExtensionsClientOutputs m_extensions; 64 RefPtr<ArrayBuffer> m_clientDataJSON; 55 65 }; 56 66 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h
r253397 r253398 35 35 class AuthenticatorResponse; 36 36 37 struct PublicKeyCredentialData { 37 struct AuthenticatorResponseData { 38 bool isAuthenticatorAttestationResponse; 39 40 // AuthenticatorResponse 38 41 RefPtr<ArrayBuffer> rawId; 39 42 40 // AuthenticatorResponse 41 bool isAuthenticatorAttestationResponse; 42 RefPtr<ArrayBuffer> clientDataJSON; 43 // Extensions 44 Optional<bool> appid; 43 45 44 46 // AuthenticatorAttestationResponse … … 50 52 RefPtr<ArrayBuffer> userHandle; 51 53 52 // Extensions53 Optional<bool> appid;54 55 54 template<class Encoder> void encode(Encoder&) const; 56 template<class Decoder> static Optional< PublicKeyCredentialData> decode(Decoder&);55 template<class Decoder> static Optional<AuthenticatorResponseData> decode(Decoder&); 57 56 }; 58 57 59 // Noted: clientDataJSON is never encoded or decoded as it is never sent across different processes.60 58 template<class Encoder> 61 void PublicKeyCredentialData::encode(Encoder& encoder) const59 void AuthenticatorResponseData::encode(Encoder& encoder) const 62 60 { 63 61 if (!rawId) { … … 98 96 99 97 template<class Decoder> 100 Optional< PublicKeyCredentialData> PublicKeyCredentialData::decode(Decoder& decoder)98 Optional<AuthenticatorResponseData> AuthenticatorResponseData::decode(Decoder& decoder) 101 99 { 102 PublicKeyCredentialData result;100 AuthenticatorResponseData result; 103 101 104 102 Optional<bool> isEmpty; -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
r251295 r253398 29 29 #if ENABLE(WEB_AUTHN) 30 30 31 #include "AuthenticatorAssertionResponse.h"32 #include "AuthenticatorAttestationResponse.h"33 31 #include "AuthenticatorCoordinator.h" 34 32 #include "AuthenticatorResponse.h" … … 36 34 #include "JSDOMPromiseDeferred.h" 37 35 #include "Page.h" 38 #include "PublicKeyCredentialData.h"39 36 #include "RuntimeEnabledFeatures.h" 40 37 #include <wtf/text/Base64.h> … … 42 39 namespace WebCore { 43 40 44 Ref Ptr<PublicKeyCredential> PublicKeyCredential::tryCreate(PublicKeyCredentialData&& data)41 Ref<PublicKeyCredential> PublicKeyCredential::create(Ref<AuthenticatorResponse>&& response) 45 42 { 46 if (!data.rawId || !data.clientDataJSON) 47 return nullptr; 48 49 if (data.isAuthenticatorAttestationResponse) { 50 if (!data.attestationObject) 51 return nullptr; 52 53 return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull()), { data.appid })); 54 } 55 56 if (!data.authenticatorData || !data.signature) 57 return nullptr; 58 59 return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle)), { data.appid })); 43 return adoptRef(*new PublicKeyCredential(WTFMove(response))); 60 44 } 61 45 62 PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response, AuthenticationExtensionsClientOutputs&& extensions) 63 : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote) 64 , m_rawId(WTFMove(id)) 65 , m_response(WTFMove(response)) 66 , m_extensions(WTFMove(extensions)) 46 ArrayBuffer* PublicKeyCredential::rawId() const 67 47 { 48 return m_response->rawId(); 68 49 } 69 50 70 PublicKeyCredential::AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const51 AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const 71 52 { 72 return m_extensions; 53 return m_response->extensions(); 54 } 55 56 PublicKeyCredential::PublicKeyCredential(Ref<AuthenticatorResponse>&& response) 57 : BasicCredential(WTF::base64URLEncode(response->rawId()->data(), response->rawId()->byteLength()), Type::PublicKey, Discovery::Remote) 58 , m_response(WTFMove(response)) 59 { 73 60 } 74 61 -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.h
r251295 r253398 29 29 30 30 #include "BasicCredential.h" 31 #include "ExceptionOr.h"32 31 #include "IDLTypes.h" 33 #include <JavaScriptCore/ArrayBuffer.h>34 32 #include <wtf/Forward.h> 35 33 … … 39 37 class Document; 40 38 41 struct PublicKeyCredentialData;39 struct AuthenticationExtensionsClientOutputs; 42 40 43 41 template<typename IDLType> class DOMPromiseDeferred; … … 45 43 class PublicKeyCredential final : public BasicCredential { 46 44 public: 47 struct AuthenticationExtensionsClientOutputs { 48 Optional<bool> appid; 49 }; 45 static Ref<PublicKeyCredential> create(Ref<AuthenticatorResponse>&&); 50 46 51 static RefPtr<PublicKeyCredential> tryCreate(PublicKeyCredentialData&&); 52 53 ArrayBuffer* rawId() const { return m_rawId.ptr(); } 47 ArrayBuffer* rawId() const; 54 48 AuthenticatorResponse* response() const { return m_response.ptr(); } 55 49 AuthenticationExtensionsClientOutputs getClientExtensionResults() const; … … 58 52 59 53 private: 60 PublicKeyCredential(Ref<A rrayBuffer>&& id, Ref<AuthenticatorResponse>&&, AuthenticationExtensionsClientOutputs&&);54 PublicKeyCredential(Ref<AuthenticatorResponse>&&); 61 55 62 56 Type credentialType() const final { return Type::PublicKey; } 63 57 64 Ref<ArrayBuffer> m_rawId;65 58 Ref<AuthenticatorResponse> m_response; 66 AuthenticationExtensionsClientOutputs m_extensions;67 59 }; 68 60 -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl
r243193 r253398 36 36 [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable(); 37 37 }; 38 39 [40 Conditional=WEB_AUTHN,41 JSGenerateToJSObject,42 ] dictionary AuthenticationExtensionsClientOutputs {43 boolean appid;44 }; -
trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.cpp
r249927 r253398 86 86 // Decodes byte array response from authenticator to CBOR value object and 87 87 // checks for correct encoding format. 88 Optional<PublicKeyCredentialData> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, const WebCore::AttestationConveyancePreference& attestation)88 RefPtr<AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, const AttestationConveyancePreference& attestation) 89 89 { 90 90 if (inBuffer.size() <= kResponseCodeLength) 91 return WTF::nullopt;91 return nullptr; 92 92 93 93 Vector<uint8_t> buffer; … … 95 95 Optional<CBOR> decodedResponse = cbor::CBORReader::read(buffer); 96 96 if (!decodedResponse || !decodedResponse->isMap()) 97 return WTF::nullopt;97 return nullptr; 98 98 const auto& decodedMap = decodedResponse->getMap(); 99 99 100 100 auto it = decodedMap.find(CBOR(1)); 101 101 if (it == decodedMap.end() || !it->second.isString()) 102 return WTF::nullopt;102 return nullptr; 103 103 auto format = it->second.clone(); 104 104 105 105 it = decodedMap.find(CBOR(2)); 106 106 if (it == decodedMap.end() || !it->second.isByteString()) 107 return WTF::nullopt;107 return nullptr; 108 108 auto authenticatorData = it->second.clone(); 109 109 110 110 auto credentialId = getCredentialId(authenticatorData.getByteString()); 111 111 if (credentialId.isEmpty()) 112 return WTF::nullopt;112 return nullptr; 113 113 114 114 it = decodedMap.find(CBOR(3)); 115 115 if (it == decodedMap.end() || !it->second.isMap()) 116 return WTF::nullopt;116 return nullptr; 117 117 auto attStmt = it->second.clone(); 118 118 … … 131 131 } 132 132 133 return PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.value().data(), attestationObject.value().size()), nullptr, nullptr, nullptr, WTF::nullopt };134 } 135 136 Optional<PublicKeyCredentialData> readCTAPGetAssertionResponse(const Vector<uint8_t>& inBuffer)133 return AuthenticatorAttestationResponse::create(credentialId, *attestationObject); 134 } 135 136 RefPtr<AuthenticatorAssertionResponse> readCTAPGetAssertionResponse(const Vector<uint8_t>& inBuffer) 137 137 { 138 138 if (inBuffer.size() <= kResponseCodeLength) 139 return WTF::nullopt;139 return nullptr; 140 140 141 141 Vector<uint8_t> buffer; … … 144 144 145 145 if (!decodedResponse || !decodedResponse->isMap()) 146 return WTF::nullopt;146 return nullptr; 147 147 148 148 auto& responseMap = decodedResponse->getMap(); 149 149 150 RefPtr<ArrayBuffer> credentialId;151 150 auto it = responseMap.find(CBOR(1)); 152 if (it != responseMap.end() && it->second.isMap()) { 153 auto& credential = it->second.getMap(); 154 auto itr = credential.find(CBOR(kCredentialIdKey)); 155 if (itr == credential.end() || !itr->second.isByteString()) 156 return WTF::nullopt; 157 auto& id = itr->second.getByteString(); 158 credentialId = ArrayBuffer::create(id.data(), id.size()); 159 } 151 if (it == responseMap.end() || !it->second.isMap()) 152 return nullptr; 153 auto& credential = it->second.getMap(); 154 auto itr = credential.find(CBOR(kCredentialIdKey)); 155 if (itr == credential.end() || !itr->second.isByteString()) 156 return nullptr; 157 auto& credentialId = itr->second.getByteString(); 160 158 161 159 it = responseMap.find(CBOR(2)); 162 160 if (it == responseMap.end() || !it->second.isByteString()) 163 return WTF::nullopt;161 return nullptr; 164 162 auto& authData = it->second.getByteString(); 165 163 166 164 it = responseMap.find(CBOR(3)); 167 165 if (it == responseMap.end() || !it->second.isByteString()) 168 return WTF::nullopt;166 return nullptr; 169 167 auto& signature = it->second.getByteString(); 170 168 171 RefPtr<ArrayBuffer> userHandle;172 169 it = responseMap.find(CBOR(4)); 173 170 if (it != responseMap.end() && it->second.isMap()) { … … 175 172 auto itr = user.find(CBOR(kEntityIdMapKey)); 176 173 if (itr == user.end() || !itr->second.isByteString()) 177 return WTF::nullopt;178 auto& id= itr->second.getByteString();179 userHandle = ArrayBuffer::create(id.data(), id.size());180 } 181 182 return PublicKeyCredentialData { WTFMove(credentialId), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), WTFMove(userHandle), WTF::nullopt };174 return nullptr; 175 auto& userHandle = itr->second.getByteString(); 176 return AuthenticatorAssertionResponse::create(credentialId, authData, signature, userHandle); 177 } 178 179 return AuthenticatorAssertionResponse::create(credentialId, authData, signature, { }); 183 180 } 184 181 -
trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.h
r245638 r253398 33 33 34 34 #include "AttestationConveyancePreference.h" 35 #include "AuthenticatorAssertionResponse.h" 36 #include "AuthenticatorAttestationResponse.h" 35 37 #include "AuthenticatorGetInfoResponse.h" 36 38 #include "FidoConstants.h" 37 #include "PublicKeyCredentialData.h"38 39 39 40 // Converts response from authenticators to CTAPResponse objects. If the … … 50 51 // CBOR map keys that conform to format of attestation object defined by the 51 52 // WebAuthN spec : https://w3c.github.io/webauthn/#fig-attStructs 52 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);53 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct); 53 54 54 55 // De-serializes CBOR encoded response to AuthenticatorGetAssertion / 55 56 // AuthenticatorGetNextAssertion request to AuthenticatorGetAssertionResponse 56 57 // object. 57 // FIXME(190783): Probably need to remake AuthenticatorResponse to include more fields like numberOfCredentials, 58 // and use it here instead of PublicKeyCredentialData. 59 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readCTAPGetAssertionResponse(const Vector<uint8_t>&); 58 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readCTAPGetAssertionResponse(const Vector<uint8_t>&); 60 59 61 60 // De-serializes CBOR encoded response to AuthenticatorGetInfo request to -
trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp
r251089 r253398 148 148 } // namespace 149 149 150 Optional<PublicKeyCredentialData> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const AttestationConveyancePreference& attestation)150 RefPtr<AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const AttestationConveyancePreference& attestation) 151 151 { 152 152 auto publicKey = extractECPublicKeyFromU2fRegistrationResponse(u2fData); 153 153 if (publicKey.isEmpty()) 154 return WTF::nullopt;154 return nullptr; 155 155 156 156 auto attestedCredentialData = createAttestedCredentialDataFromU2fRegisterResponse(u2fData, publicKey); 157 157 if (attestedCredentialData.isEmpty()) 158 return WTF::nullopt;158 return nullptr; 159 159 160 160 // Extract the credentialId for packing into the response data. … … 167 167 auto fidoAttestationStatement = createFidoAttestationStatementFromU2fRegisterResponse(u2fData, kU2fKeyHandleOffset + credentialId.size()); 168 168 if (fidoAttestationStatement.empty()) 169 return WTF::nullopt;169 return nullptr; 170 170 171 171 auto attestationObject = buildAttestationObject(WTFMove(authData), "fido-u2f", WTFMove(fidoAttestationStatement), attestation); 172 172 173 return PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.data(), attestationObject.size()), nullptr, nullptr, nullptr, WTF::nullopt };173 return AuthenticatorAttestationResponse::create(credentialId, attestationObject); 174 174 } 175 175 176 Optional<PublicKeyCredentialData> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData)176 RefPtr<AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData) 177 177 { 178 178 if (keyHandle.isEmpty() || u2fData.size() <= signatureIndex) 179 return WTF::nullopt;179 return nullptr; 180 180 181 181 // 1 byte flags, 4 bytes counter … … 187 187 auto authData = buildAuthData(rpId, flags, counter, { }); 188 188 189 return PublicKeyCredentialData { ArrayBuffer::create(keyHandle.data(), keyHandle.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(u2fData.data() + signatureIndex, u2fData.size() - signatureIndex), nullptr, WTF::nullopt }; 189 // FIXME: Find a way to remove the need of constructing a vector here. 190 Vector<uint8_t> signature; 191 signature.append(u2fData.data() + signatureIndex, u2fData.size() - signatureIndex); 192 193 return AuthenticatorAssertionResponse::create(keyHandle, authData, signature, { }); 190 194 } 191 195 -
trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h
r245638 r253398 33 33 34 34 #include "AttestationConveyancePreference.h" 35 #include "PublicKeyCredentialData.h" 35 #include "AuthenticatorAssertionResponse.h" 36 #include "AuthenticatorAttestationResponse.h" 36 37 #include <wtf/Forward.h> 37 38 … … 40 41 // Converts a U2F register response to WebAuthN makeCredential response. 41 42 // https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorMakeCredential-interoperability 42 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);43 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct); 43 44 44 45 // Converts a U2F authentication response to WebAuthN getAssertion response. 45 46 // https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorGetAssertion-interoperability 46 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData);47 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData); 47 48 48 49 } // namespace fido -
trunk/Source/WebCore/Sources.txt
r253254 r253398 269 269 270 270 Modules/webauthn/AuthenticatorCoordinator.cpp 271 Modules/webauthn/AuthenticatorAssertionResponse.cpp 272 Modules/webauthn/AuthenticatorAttestationResponse.cpp 273 Modules/webauthn/AuthenticatorResponse.cpp 271 274 Modules/webauthn/PublicKeyCredential.cpp 272 275 Modules/webauthn/WebAuthenticationUtils.cpp … … 2654 2657 JSAttestationConveyancePreference.cpp 2655 2658 JSAuthenticationExtensionsClientInputs.cpp 2659 JSAuthenticationExtensionsClientOutputs.cpp 2656 2660 JSAuthenticatorAssertionResponse.cpp 2657 2661 JSAuthenticatorAttestationResponse.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r253351 r253398 1774 1774 57303BBB2006C6EE00355965 /* CBORBinary.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BB62006C6ED00355965 /* CBORBinary.h */; }; 1775 1775 57303BC12006E00C00355965 /* CBORReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BBF2006E00C00355965 /* CBORReader.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1776 57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BCF20087A8300355965 /* AuthenticatorResponse.h */; };1776 57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BCF20087A8300355965 /* AuthenticatorResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1777 1777 57303BE120095D6100355965 /* JSAuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BDD20095B2600355965 /* JSAuthenticatorResponse.h */; }; 1778 1778 57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1784 1784 57303C1120099CB100355965 /* JSPublicKeyCredentialRequestOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C0C20099C7500355965 /* JSPublicKeyCredentialRequestOptions.h */; }; 1785 1785 57303C192009A2F300355965 /* JSPublicKeyCredentialCreationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C132009A25700355965 /* JSPublicKeyCredentialCreationOptions.h */; }; 1786 57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */; };1786 57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1787 1787 57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */; }; 1788 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };1788 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1789 1789 57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; }; 1790 1790 57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1799 1799 5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; }; 1800 1800 5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; }; 1801 57585961239F124D00C74572 /* JSAuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */; }; 1802 5758596C239F321C00C74572 /* AuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1801 1803 5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1802 1804 5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; }; … … 1826 1828 57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; }; 1827 1829 57DA47B0224034E4002A4612 /* AuthenticationExtensionsClientInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DA47A522401E0F002A4612 /* AuthenticationExtensionsClientInputs.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1828 57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */; settings = {ATTRIBUTES = (Private, ); }; };1830 57DCED74214305F00016B847 /* AuthenticatorResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* AuthenticatorResponseData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1829 1831 57DCED9021487FF70016B847 /* AuthenticatorTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1830 1832 57DCED98214882160016B847 /* JSAuthenticatorTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED92214880C60016B847 /* JSAuthenticatorTransport.h */; }; … … 8783 8785 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaPssParams.h; sourceTree = "<group>"; }; 8784 8786 5754719A1ECE5D2A00DD63B2 /* JSRsaPssParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaPssParams.cpp; sourceTree = "<group>"; }; 8787 5758595C239F113000C74572 /* JSAuthenticationExtensionsClientOutputs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticationExtensionsClientOutputs.cpp; sourceTree = "<group>"; }; 8788 5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSAuthenticationExtensionsClientOutputs.h; sourceTree = "<group>"; }; 8789 57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticationExtensionsClientOutputs.h; sourceTree = "<group>"; }; 8790 57585967239F14CD00C74572 /* AuthenticationExtensionsClientOutputs.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticationExtensionsClientOutputs.idl; sourceTree = "<group>"; }; 8791 57585969239F1EC700C74572 /* AuthenticatorResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorResponse.cpp; sourceTree = "<group>"; }; 8792 5758596B239F284B00C74572 /* AuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; }; 8793 5758596E239F397900C74572 /* AuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; }; 8785 8794 5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; }; 8786 8795 576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; }; … … 8853 8862 57DA47AC224032DC002A4612 /* JSAuthenticationExtensionsClientInputs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticationExtensionsClientInputs.cpp; sourceTree = "<group>"; }; 8854 8863 57DA47AD224032DD002A4612 /* JSAuthenticationExtensionsClientInputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSAuthenticationExtensionsClientInputs.h; sourceTree = "<group>"; }; 8855 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialData.h; sourceTree = "<group>"; };8864 57DCED72214305F00016B847 /* AuthenticatorResponseData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorResponseData.h; sourceTree = "<group>"; }; 8856 8865 57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorTransport.h; sourceTree = "<group>"; }; 8857 8866 57DCED8E21487EDB0016B847 /* AuthenticatorTransport.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorTransport.idl; sourceTree = "<group>"; }; … … 20029 20038 57DA47A522401E0F002A4612 /* AuthenticationExtensionsClientInputs.h */, 20030 20039 57DA47A722401E0F002A4612 /* AuthenticationExtensionsClientInputs.idl */, 20040 57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */, 20041 57585967239F14CD00C74572 /* AuthenticationExtensionsClientOutputs.idl */, 20042 5758596E239F397900C74572 /* AuthenticatorAssertionResponse.cpp */, 20031 20043 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */, 20032 20044 57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */, 20045 5758596B239F284B00C74572 /* AuthenticatorAttestationResponse.cpp */, 20033 20046 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */, 20034 20047 57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */, … … 20036 20049 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */, 20037 20050 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */, 20051 57585969239F1EC700C74572 /* AuthenticatorResponse.cpp */, 20038 20052 57303BCF20087A8300355965 /* AuthenticatorResponse.h */, 20039 20053 57303BD120087A8300355965 /* AuthenticatorResponse.idl */, 20054 57DCED72214305F00016B847 /* AuthenticatorResponseData.h */, 20040 20055 57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */, 20041 20056 57DCED8E21487EDB0016B847 /* AuthenticatorTransport.idl */, … … 20045 20060 57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */, 20046 20061 57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */, 20047 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */,20048 20062 57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */, 20049 20063 57303BEE200980BF00355965 /* PublicKeyCredentialDescriptor.idl */, … … 20068 20082 57DA47AC224032DC002A4612 /* JSAuthenticationExtensionsClientInputs.cpp */, 20069 20083 57DA47AD224032DD002A4612 /* JSAuthenticationExtensionsClientInputs.h */, 20084 5758595C239F113000C74572 /* JSAuthenticationExtensionsClientOutputs.cpp */, 20085 5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */, 20070 20086 57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */, 20071 20087 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */, … … 29043 29059 E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */, 29044 29060 57DA47B0224034E4002A4612 /* AuthenticationExtensionsClientInputs.h in Headers */, 29061 5758596C239F321C00C74572 /* AuthenticationExtensionsClientOutputs.h in Headers */, 29045 29062 514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */, 29046 29063 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */, … … 29050 29067 572B40422178114A000AD43E /* AuthenticatorGetInfoResponse.h in Headers */, 29051 29068 57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */, 29069 57DCED74214305F00016B847 /* AuthenticatorResponseData.h in Headers */, 29052 29070 572B404021780171000AD43E /* AuthenticatorSupportedOptions.h in Headers */, 29053 29071 57DCED9021487FF70016B847 /* AuthenticatorTransport.h in Headers */, … … 30401 30419 BE8EF045171C8FF9009B48C3 /* JSAudioTrackList.h in Headers */, 30402 30420 57D1352A2294AA3900827401 /* JSAuthenticationExtensionsClientInputs.h in Headers */, 30421 57585961239F124D00C74572 /* JSAuthenticationExtensionsClientOutputs.h in Headers */, 30403 30422 57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */, 30404 30423 57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */, … … 31776 31795 57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */, 31777 31796 57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */, 31778 57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */,31779 31797 57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */, 31780 31798 57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */, -
trunk/Source/WebKit/ChangeLog
r253396 r253398 1 2019-12-11 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData 4 https://bugs.webkit.org/show_bug.cgi?id=190783 5 <rdar://problem/57781183> 6 7 Reviewed by Brent Fulgham. 8 9 Code in WebKit are changed to use AuthenticatorResponse and its subtypes. 10 11 * UIProcess/WebAuthentication/Authenticator.h: 12 * UIProcess/WebAuthentication/AuthenticatorManager.cpp: 13 (WebKit::AuthenticatorManager::respondReceived): 14 (WebKit::AuthenticatorManager::invokePendingCompletionHandler): 15 * UIProcess/WebAuthentication/AuthenticatorManager.h: 16 * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: 17 (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested): 18 (WebKit::LocalAuthenticator::continueGetAssertionAfterUserConsented): 19 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: 20 (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest): 21 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: 22 * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: 23 * UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp: 24 (WebKit::CtapAuthenticator::continueMakeCredentialAfterResponseReceived const): 25 (WebKit::CtapAuthenticator::continueGetAssertionAfterResponseReceived): 26 * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp: 27 (WebKit::U2fAuthenticator::continueRegisterCommandAfterResponseReceived): 28 (WebKit::U2fAuthenticator::continueSignCommandAfterResponseReceived): 29 * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: 30 1 31 2019-12-11 Truitt Savell <tsavell@apple.com> 2 32 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Authenticator.h
r251317 r253398 30 30 #include "WebAuthenticationFlags.h" 31 31 #include "WebAuthenticationRequestData.h" 32 #include <WebCore/AuthenticatorResponse.h> 32 33 #include <WebCore/ExceptionData.h> 33 #include <WebCore/PublicKeyCredentialData.h>34 34 #include <wtf/Forward.h> 35 35 #include <wtf/RefCounted.h> … … 40 40 class Authenticator : public RefCounted<Authenticator>, public CanMakeWeakPtr<Authenticator> { 41 41 public: 42 using Respond = Variant< WebCore::PublicKeyCredentialData, WebCore::ExceptionData>;42 using Respond = Variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>; 43 43 44 44 class Observer : public CanMakeWeakPtr<Observer> { -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp
r252492 r253398 244 244 ASSERT(m_pendingCompletionHandler); 245 245 246 auto shouldComplete = WTF::holds_alternative< PublicKeyCredentialData>(respond);246 auto shouldComplete = WTF::holds_alternative<Ref<AuthenticatorResponse>>(respond); 247 247 if (!shouldComplete) 248 248 shouldComplete = WTF::get<ExceptionData>(respond).code == InvalidStateError; … … 350 350 { 351 351 if (auto *panel = m_pendingRequestData.panel.get()) { 352 WTF::switchOn(respond, [&](const PublicKeyCredentialData&) {352 WTF::switchOn(respond, [&](const Ref<AuthenticatorResponse>&) { 353 353 panel->client().dismissPanel(WebAuthenticationResult::Succeeded); 354 354 }, [&](const ExceptionData&) { -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
r252248 r253398 31 31 #include "AuthenticatorTransportService.h" 32 32 #include "WebAuthenticationRequestData.h" 33 #include <WebCore/AuthenticatorResponse.h> 33 34 #include <WebCore/ExceptionData.h> 34 #include <WebCore/PublicKeyCredentialData.h>35 35 #include <wtf/CompletionHandler.h> 36 36 #include <wtf/HashSet.h> … … 49 49 WTF_MAKE_NONCOPYABLE(AuthenticatorManager); 50 50 public: 51 using Respond = Variant< WebCore::PublicKeyCredentialData, WebCore::ExceptionData>;51 using Respond = Variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>; 52 52 using Callback = CompletionHandler<void(Respond&&)>; 53 53 using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm
r250249 r253398 30 30 31 31 #import <Security/SecItem.h> 32 #import <WebCore/AuthenticatorAssertionResponse.h> 33 #import <WebCore/AuthenticatorAttestationResponse.h> 32 34 #import <WebCore/CBORWriter.h> 33 35 #import <WebCore/ExceptionData.h> 34 36 #import <WebCore/PublicKeyCredentialCreationOptions.h> 35 #import <WebCore/PublicKeyCredentialData.h>36 37 #import <WebCore/PublicKeyCredentialRequestOptions.h> 37 38 #import <WebCore/WebAuthenticationConstants.h> … … 341 342 auto attestationObject = buildAttestationObject(WTFMove(authData), "Apple", WTFMove(attestationStatementMap), creationOptions.attestation); 342 343 343 receiveRespond( PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.data(), attestationObject.size()), nullptr, nullptr, nullptr, WTF::nullopt });344 receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject)); 344 345 } 345 346 … … 482 483 483 484 // Step 13. 484 receiveRespond( PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userhandle.data(), userhandle.size()), WTF::nullopt });485 receiveRespond(AuthenticatorAssertionResponse::create(credentialId, authData, signature, userhandle)); 485 486 } 486 487 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
r251489 r253398 36 36 #include "WebProcessProxy.h" 37 37 #include "WebsiteDataStore.h" 38 #include <WebCore/AuthenticatorResponseData.h> 38 39 #include <WebCore/ExceptionData.h> 39 #include <WebCore/PublicKeyCredentialData.h>40 40 #include <WebCore/SecurityOriginData.h> 41 41 #include <wtf/MainThread.h> … … 68 68 void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler) 69 69 { 70 auto callback = [handler = WTFMove(handler)] (Variant< PublicKeyCredentialData, ExceptionData>&& result) mutable {70 auto callback = [handler = WTFMove(handler)] (Variant<Ref<AuthenticatorResponse>, ExceptionData>&& result) mutable { 71 71 ASSERT(RunLoop::isMain()); 72 WTF::switchOn(result, [&](const PublicKeyCredentialData& data) {73 handler( data, { });72 WTF::switchOn(result, [&](const Ref<AuthenticatorResponse>& response) { 73 handler(response->data(), { }); 74 74 }, [&](const ExceptionData& exception) { 75 75 handler({ }, exception); -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h
r251489 r253398 36 36 struct ExceptionData; 37 37 struct PublicKeyCredentialCreationOptions; 38 struct PublicKeyCredentialData;38 struct AuthenticatorResponseData; 39 39 struct PublicKeyCredentialRequestOptions; 40 40 struct SecurityOriginData; … … 55 55 56 56 private: 57 using RequestCompletionHandler = CompletionHandler<void(const WebCore:: PublicKeyCredentialData&, const WebCore::ExceptionData&)>;57 using RequestCompletionHandler = CompletionHandler<void(const WebCore::AuthenticatorResponseData&, const WebCore::ExceptionData&)>; 58 58 using QueryCompletionHandler = CompletionHandler<void(bool)>; 59 59 -
trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in
r252655 r253398 27 27 messages -> WebAuthenticatorCoordinatorProxy NotRefCounted { 28 28 29 MakeCredential(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore:: PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async30 GetAssertion(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore:: PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async29 MakeCredential(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore::AuthenticatorResponseData data, struct WebCore::ExceptionData exception) Async 30 GetAssertion(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore::AuthenticatorResponseData data, struct WebCore::ExceptionData exception) Async 31 31 IsUserVerifyingPlatformAuthenticatorAvailable() -> (bool result) Async 32 32 } -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp
r251979 r253398 74 74 return; 75 75 } 76 receiveRespond( WTFMove(*response));76 receiveRespond(response.releaseNonNull()); 77 77 } 78 78 … … 101 101 return; 102 102 } 103 receiveRespond( WTFMove(*response));103 receiveRespond(response.releaseNonNull()); 104 104 } 105 105 -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp
r251645 r253398 162 162 return; 163 163 } 164 receiveRespond( WTFMove(*response));164 receiveRespond(response.releaseNonNull()); 165 165 return; 166 166 } … … 206 206 switch (apduResponse.status()) { 207 207 case ApduResponse::Status::SW_NO_ERROR: { 208 Optional<PublicKeyCredentialData> response;208 RefPtr<AuthenticatorAssertionResponse> response; 209 209 if (m_isAppId) { 210 210 ASSERT(requestOptions.extensions && !requestOptions.extensions->appid.isNull()); … … 217 217 } 218 218 if (m_isAppId) 219 response-> appid = m_isAppId;220 221 receiveRespond( WTFMove(*response));219 response->setExtensions({ m_isAppId }); 220 221 receiveRespond(response.releaseNonNull()); 222 222 return; 223 223 } -
trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
r251489 r253398 32 32 #include "WebFrame.h" 33 33 #include "WebPage.h" 34 #include <WebCore/AuthenticatorResponseData.h> 34 35 #include <WebCore/PublicKeyCredentialCreationOptions.h> 35 #include <WebCore/PublicKeyCredentialData.h>36 36 #include <WebCore/PublicKeyCredentialRequestOptions.h> 37 37 #include <WebCore/SecurityOrigin.h> -
trunk/Tools/ChangeLog
r253396 r253398 1 2019-12-11 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData 4 https://bugs.webkit.org/show_bug.cgi?id=190783 5 <rdar://problem/57781183> 6 7 Reviewed by Brent Fulgham. 8 9 * TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp: 10 (TestWebKitAPI::TEST): 11 Updates tests accordingly. 12 1 13 2019-12-11 Truitt Savell <tsavell@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp
r249927 r253398 356 356 auto makeCredentialResponse = readCTAPMakeCredentialResponse(convertBytesToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse))); 357 357 ASSERT_TRUE(makeCredentialResponse); 358 auto cborAttestationObject = cbor::CBORReader::read(convertBytesToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject ->data()), makeCredentialResponse->attestationObject->byteLength()));358 auto cborAttestationObject = cbor::CBORReader::read(convertBytesToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject()->data()), makeCredentialResponse->attestationObject()->byteLength())); 359 359 ASSERT_TRUE(cborAttestationObject); 360 360 ASSERT_TRUE(cborAttestationObject->isMap()); … … 394 394 ASSERT_TRUE(certificate.getArray()[0].isByteString()); 395 395 EXPECT_EQ(certificate.getArray()[0].getByteString(), convertBytesToVector(TestData::kCtap2MakeCredentialCertificate, sizeof(TestData::kCtap2MakeCredentialCertificate))); 396 EXPECT_EQ(makeCredentialResponse->rawId ->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId));397 EXPECT_EQ(memcmp(makeCredentialResponse->rawId ->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0);396 EXPECT_EQ(makeCredentialResponse->rawId()->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId)); 397 EXPECT_EQ(memcmp(makeCredentialResponse->rawId()->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0); 398 398 } 399 399 … … 405 405 ASSERT_TRUE(getAssertionResponse); 406 406 407 EXPECT_EQ(getAssertionResponse->authenticatorData ->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData));408 EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData ->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0);409 EXPECT_EQ(getAssertionResponse->signature ->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature));410 EXPECT_EQ(memcmp(getAssertionResponse->signature ->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0);407 EXPECT_EQ(getAssertionResponse->authenticatorData()->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData)); 408 EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData()->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0); 409 EXPECT_EQ(getAssertionResponse->signature()->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature)); 410 EXPECT_EQ(memcmp(getAssertionResponse->signature()->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0); 411 411 } 412 412 … … 416 416 auto response = readU2fRegisterResponse(TestData::kRelyingPartyId, convertBytesToVector(TestData::kTestU2fRegisterResponse, sizeof(TestData::kTestU2fRegisterResponse))); 417 417 ASSERT_TRUE(response); 418 EXPECT_EQ(response->rawId->byteLength(), sizeof(TestData::kU2fSignKeyHandle)); 419 EXPECT_EQ(memcmp(response->rawId->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0); 420 EXPECT_TRUE(response->isAuthenticatorAttestationResponse); 418 EXPECT_EQ(response->rawId()->byteLength(), sizeof(TestData::kU2fSignKeyHandle)); 419 EXPECT_EQ(memcmp(response->rawId()->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0); 421 420 auto expectedAttestationObject = getTestAttestationObjectBytes(); 422 EXPECT_EQ(response->attestationObject ->byteLength(), expectedAttestationObject.size());423 EXPECT_EQ(memcmp(response->attestationObject ->data(), expectedAttestationObject.data(), expectedAttestationObject.size()), 0);421 EXPECT_EQ(response->attestationObject()->byteLength(), expectedAttestationObject.size()); 422 EXPECT_EQ(memcmp(response->attestationObject()->data(), expectedAttestationObject.data(), expectedAttestationObject.size()), 0); 424 423 } 425 424 … … 523 522 auto response = readU2fSignResponse(TestData::kRelyingPartyId, getTestCredentialRawIdBytes(), getTestSignResponse()); 524 523 ASSERT_TRUE(response); 525 EXPECT_EQ(response->rawId->byteLength(), sizeof(TestData::kU2fSignKeyHandle)); 526 EXPECT_EQ(memcmp(response->rawId->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0); 527 EXPECT_FALSE(response->isAuthenticatorAttestationResponse); 528 EXPECT_EQ(response->authenticatorData->byteLength(), sizeof(TestData::kTestSignAuthenticatorData)); 529 EXPECT_EQ(memcmp(response->authenticatorData->data(), TestData::kTestSignAuthenticatorData, sizeof(TestData::kTestSignAuthenticatorData)), 0); 530 EXPECT_EQ(response->signature->byteLength(), sizeof(TestData::kU2fSignature)); 531 EXPECT_EQ(memcmp(response->signature->data(), TestData::kU2fSignature, sizeof(TestData::kU2fSignature)), 0); 524 EXPECT_EQ(response->rawId()->byteLength(), sizeof(TestData::kU2fSignKeyHandle)); 525 EXPECT_EQ(memcmp(response->rawId()->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0); 526 EXPECT_EQ(response->authenticatorData()->byteLength(), sizeof(TestData::kTestSignAuthenticatorData)); 527 EXPECT_EQ(memcmp(response->authenticatorData()->data(), TestData::kTestSignAuthenticatorData, sizeof(TestData::kTestSignAuthenticatorData)), 0); 528 EXPECT_EQ(response->signature()->byteLength(), sizeof(TestData::kU2fSignature)); 529 EXPECT_EQ(memcmp(response->signature()->data(), TestData::kU2fSignature, sizeof(TestData::kU2fSignature)), 0); 532 530 } 533 531
Note: See TracChangeset
for help on using the changeset viewer.