Skip to content

Commit

Permalink
Revert "Apply patch. rdar://122813058"
Browse files Browse the repository at this point in the history
This reverts commit 33db5f5.

Identifier: 272448.574@safari-7618.1.15.10-branch
  • Loading branch information
Dan Robson committed Feb 15, 2024
1 parent 1cdb2f6 commit b2e9aa1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 63 deletions.
17 changes: 0 additions & 17 deletions Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ void AuthenticatorCoordinator::create(const Document& document, CredentialCreati
}

options.extensions = extensionInputs;
if (options.extensions && options.extensions->largeBlob) {
if (options.extensions->largeBlob->read || options.extensions->largeBlob->write) {
promise.reject(Exception { ExceptionCode::NotAllowedError, "Read and write may not be present in largeBlob for registration."_s });
return;
}
}

// Step 4, 18-22.
if (!m_client) {
Expand Down Expand Up @@ -242,17 +236,6 @@ void AuthenticatorCoordinator::discoverFromExternalSource(const Document& docume
options.extensions->appid = appid;
}

if (options.extensions && options.extensions->largeBlob) {
if (!options.extensions->largeBlob->support.isEmpty()) {
promise.reject(Exception { ExceptionCode::NotAllowedError, "Support should not be present in largeBlob for assertion."_s });
return;
}
if (options.extensions->largeBlob->read && options.extensions->largeBlob->write) {
promise.reject(Exception { ExceptionCode::NotAllowedError, "Both read and write may not be present together in largeBlob."_s });
return;
}
}

// Step 4, 14-19.
if (!m_client) {
promise.reject(Exception { ExceptionCode::UnknownError, "Unknown internal error."_s });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,3 @@ SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationPublicKeyCredentialParameters)
SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationPlatformPublicKeyCredentialDescriptor);
SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationSecurityKeyPublicKeyCredentialDescriptor);
SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationSecurityKeyPublicKeyCredentialAssertion);
SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationPublicKeyCredentialLargeBlobAssertionInput);
SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASAuthorizationPublicKeyCredentialLargeBlobRegistrationInput);
SOFT_LINK_CONSTANT_FOR_HEADER(WebKit, AuthenticationServices, ASAuthorizationErrorDomain, NSErrorDomain);
#define ASAuthorizationErrorDomain WebKit::get_AuthenticationServices_ASAuthorizationErrorDomain()
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@
SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationPlatformPublicKeyCredentialDescriptor);
SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationSecurityKeyPublicKeyCredentialDescriptor);
SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationSecurityKeyPublicKeyCredentialAssertion);
SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationPublicKeyCredentialLargeBlobAssertionInput);
SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationPublicKeyCredentialLargeBlobRegistrationInput);
SOFT_LINK_CONSTANT_FOR_SOURCE(WebKit, AuthenticationServices, ASAuthorizationErrorDomain, NSErrorDomain);

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <wtf/Assertions.h>
#if HAVE(UNIFIED_ASC_AUTH_UI)

#import "config.h"
Expand Down Expand Up @@ -56,7 +55,7 @@
#import "AuthenticationServicesSoftLink.h"

@interface _WKASDelegate : NSObject {
RetainPtr<WKWebView> m_view;
WeakPtr<WebKit::WebPageProxy> m_page;
BlockPtr<void(ASAuthorization *, NSError *)> m_completionHandler;
}
- (instancetype)initWithPage:(WeakPtr<WebKit::WebPageProxy> &&)page completionHandler:(BlockPtr<void(ASAuthorization *, NSError *)> &&)completionHandler;
Expand All @@ -68,8 +67,7 @@ - (instancetype)initWithPage:(WeakPtr<WebKit::WebPageProxy> &&)page completionHa
if (!(self = [super init]))
return nil;

if (page)
m_view = page->cocoaView();
m_page = WTFMove(page);
m_completionHandler = WTFMove(completionHandler);

return self;
Expand All @@ -79,9 +77,7 @@ - (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthoriz
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (m_view)
return [m_view window];
return nil;
return [m_page->cocoaView() window];
#pragma clang diagnostic pop
}

Expand All @@ -107,14 +103,6 @@ - (void)authorizationController:(ASAuthorizationController *)controller didCompl

#if HAVE(WEB_AUTHN_AS_MODERN)

static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement(const String& requirement)
{
if (requirement == "required"_s)
return ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirementRequired;
return ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirementPreferred;
}


static inline RetainPtr<NSString> toASUserVerificationPreference(WebCore::UserVerificationRequirement requirement)
{
switch (requirement) {
Expand Down Expand Up @@ -215,11 +203,6 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
request.get().attestationPreference = toAttestationConveyancePreference(options.attestation).get();
if (options.authenticatorSelection)
request.get().userVerificationPreference = toASUserVerificationPreference(options.authenticatorSelection->userVerification).get();
if (options.extensions->largeBlob) {
// These are satisfied by validation in AuthenticatorCoordinator.
ASSERT(!options.extensions->largeBlob->read && !options.extensions->largeBlob->write);
request.get().largeBlob = adoptNS([allocASAuthorizationPublicKeyCredentialLargeBlobRegistrationInputInstance() initWithSupportRequirement:toASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement(options.extensions->largeBlob->support)]).get();
}
[requests addObject:request.leakRef()];
}
if (includeSecurityKeyRequest) {
Expand Down Expand Up @@ -271,15 +254,6 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
RetainPtr request = adoptNS([[allocASAuthorizationPlatformPublicKeyCredentialProviderInstance() initWithRelyingPartyIdentifier:options.rpId] createCredentialAssertionRequestWithClientData:clientData.get()]);
if (platformAllowedCredentials)
request.get().allowedCredentials = platformAllowedCredentials.get();
if (options.extensions->largeBlob) {
// These are satisfied by validation in AuthenticatorCoordinator.
ASSERT(!options.extensions->largeBlob->support);
ASSERT(!(options.extensions->largeBlob->read && options.extensions->largeBlob->write));
auto largeBlob = options.extensions->largeBlob;
request.get().largeBlob = adoptNS([allocASAuthorizationPublicKeyCredentialLargeBlobAssertionInputInstance() initWithOperation:(largeBlob->read && *largeBlob->read) ? ASAuthorizationPublicKeyCredentialLargeBlobAssertionOperationRead : ASAuthorizationPublicKeyCredentialLargeBlobAssertionOperationWrite]).get();
if (largeBlob->write)
request.get().largeBlob.dataToWrite = WebCore::toNSData(*largeBlob->write).get();
}
[requests addObject:request.leakRef()];
}

Expand Down Expand Up @@ -341,8 +315,10 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
}
m_controller = WTFMove(controller);
m_completionHandler = WTFMove(handler);
m_delegate = adoptNS([[_WKASDelegate alloc] initWithPage:WTFMove(requestData.page) completionHandler:makeBlockPtr([weakThis = WeakPtr { *this }](ASAuthorization *auth, NSError *error) mutable {
ensureOnMainRunLoop([weakThis = WTFMove(weakThis), auth = retainPtr(auth), error = retainPtr(error)]() {
m_delegate = adoptNS([[_WKASDelegate alloc] initWithPage:WTFMove(requestData.page) completionHandler:makeBlockPtr([weakThis = WeakPtr { *this }, this](ASAuthorization *auth, NSError *error) mutable {
if (!weakThis)
return;
ensureOnMainRunLoop([weakThis = WTFMove(weakThis), this, auth = retainPtr(auth)]() {
if (!weakThis)
return;
WebCore::AuthenticatorResponseData response = { };
Expand All @@ -355,21 +331,13 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
response.attestationObject = toArrayBuffer(credential.get().rawAttestationObject);
response.transports = { };
response.clientDataJSON = toArrayBuffer(credential.get().rawClientDataJSON);
if (credential.get().largeBlob)
response.extensionOutputs = { { std::nullopt, std::nullopt, { { credential.get().largeBlob.isSupported, nullptr, std::nullopt } } } };
} else if ([auth.get().credential isKindOfClass:getASAuthorizationPlatformPublicKeyCredentialAssertionClass()]) {
auto credential = retainPtr((ASAuthorizationPlatformPublicKeyCredentialAssertion *)auth.get().credential);
response.rawId = toArrayBuffer(credential.get().credentialID);
response.authenticatorData = toArrayBuffer(credential.get().rawAuthenticatorData);
response.signature = toArrayBuffer(credential.get().signature);
response.userHandle = toArrayBuffer(credential.get().userID);
response.clientDataJSON = toArrayBuffer(credential.get().rawClientDataJSON);
if (credential.get().largeBlob) {
RefPtr<ArrayBuffer> protector = nullptr;
if (credential.get().largeBlob.readData)
protector = toArrayBuffer(credential.get().largeBlob.readData);
response.extensionOutputs = { { std::nullopt, std::nullopt, { { std::nullopt, protector, credential.get().largeBlob.didWrite } } } };
}
} else if ([auth.get().credential isKindOfClass:getASAuthorizationSecurityKeyPublicKeyCredentialRegistrationClass()]) {
auto credential = retainPtr((ASAuthorizationSecurityKeyPublicKeyCredentialRegistration *)auth.get().credential);
response.isAuthenticatorAttestationResponse = true;
Expand Down

0 comments on commit b2e9aa1

Please sign in to comment.