Changeset 236344 in webkit


Ignore:
Timestamp:
Sep 21, 2018 12:25:21 PM (6 years ago)
Author:
achristensen@apple.com
Message:

Simply authentication code even more!
https://bugs.webkit.org/show_bug.cgi?id=189719

Reviewed by Andy Estes.

Just when you thought it couldn't get simpler and more elegant, it can!

  • NetworkProcess/Downloads/Download.cpp:
  • NetworkProcess/NetworkCORSPreflightChecker.cpp:
  • NetworkProcess/NetworkLoad.cpp:
  • NetworkProcess/PingLoad.cpp:
  • NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:
  • Shared/Authentication/AuthenticationChallengeDisposition.h: Added.
  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::completeAuthenticationChallenge):
(WebKit::AuthenticationManager::useCredentialForChallenge): Deleted.
(WebKit::AuthenticationManager::useCredentialForSingleChallenge): Deleted.
(WebKit::AuthenticationManager::continueWithoutCredentialForChallenge): Deleted.
(WebKit::AuthenticationManager::continueWithoutCredentialForSingleChallenge): Deleted.
(WebKit::AuthenticationManager::cancelChallenge): Deleted.
(WebKit::AuthenticationManager::cancelSingleChallenge): Deleted.
(WebKit::AuthenticationManager::performDefaultHandling): Deleted.
(WebKit::AuthenticationManager::performDefaultHandlingForSingleChallenge): Deleted.
(WebKit::AuthenticationManager::rejectProtectionSpaceAndContinue): Deleted.
(WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge): Deleted.

  • Shared/Authentication/AuthenticationManager.h:
  • Shared/Authentication/AuthenticationManager.messages.in:
  • Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:

(WebKit::AuthenticationManager::initializeConnection):

  • UIProcess/API/C/WKAuthenticationDecisionListener.cpp:

(WKAuthenticationDecisionListenerUseCredential):

  • UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm:

(-[WKNSURLAuthenticationChallengeSender continueWithoutCredentialForAuthenticationChallenge:]):

  • UIProcess/API/glib/WebKitAuthenticationRequest.cpp:

(webkit_authentication_request_authenticate):

  • UIProcess/Authentication/AuthenticationChallengeProxy.cpp:

(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):

  • UIProcess/Authentication/AuthenticationDecisionListener.cpp:

(WebKit::AuthenticationDecisionListener::AuthenticationDecisionListener):
(WebKit::AuthenticationDecisionListener::~AuthenticationDecisionListener):
(WebKit::AuthenticationDecisionListener::useCredential):
(WebKit::AuthenticationDecisionListener::cancel):
(WebKit::AuthenticationDecisionListener::performDefaultHandling):
(WebKit::AuthenticationDecisionListener::rejectProtectionSpaceAndContinue):

  • UIProcess/Authentication/AuthenticationDecisionListener.h:

(WebKit::AuthenticationDecisionListener::create):

  • UIProcess/Cocoa/DownloadClient.mm:

(WebKit::DownloadClient::didReceiveAuthenticationChallenge):

  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::NavigationClient::didReceiveAuthenticationChallenge):

  • WebKit.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebKit
Files:
1 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r236343 r236344  
     12018-09-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        Simply authentication code even more!
     4        https://bugs.webkit.org/show_bug.cgi?id=189719
     5
     6        Reviewed by Andy Estes.
     7
     8        Just when you thought it couldn't get simpler and more elegant, it can!
     9
     10        * NetworkProcess/Downloads/Download.cpp:
     11        * NetworkProcess/NetworkCORSPreflightChecker.cpp:
     12        * NetworkProcess/NetworkLoad.cpp:
     13        * NetworkProcess/PingLoad.cpp:
     14        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
     15        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     16        * Shared/Authentication/AuthenticationChallengeDisposition.h: Added.
     17        * Shared/Authentication/AuthenticationManager.cpp:
     18        (WebKit::AuthenticationManager::completeAuthenticationChallenge):
     19        (WebKit::AuthenticationManager::useCredentialForChallenge): Deleted.
     20        (WebKit::AuthenticationManager::useCredentialForSingleChallenge): Deleted.
     21        (WebKit::AuthenticationManager::continueWithoutCredentialForChallenge): Deleted.
     22        (WebKit::AuthenticationManager::continueWithoutCredentialForSingleChallenge): Deleted.
     23        (WebKit::AuthenticationManager::cancelChallenge): Deleted.
     24        (WebKit::AuthenticationManager::cancelSingleChallenge): Deleted.
     25        (WebKit::AuthenticationManager::performDefaultHandling): Deleted.
     26        (WebKit::AuthenticationManager::performDefaultHandlingForSingleChallenge): Deleted.
     27        (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinue): Deleted.
     28        (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge): Deleted.
     29        * Shared/Authentication/AuthenticationManager.h:
     30        * Shared/Authentication/AuthenticationManager.messages.in:
     31        * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
     32        (WebKit::AuthenticationManager::initializeConnection):
     33        * UIProcess/API/C/WKAuthenticationDecisionListener.cpp:
     34        (WKAuthenticationDecisionListenerUseCredential):
     35        * UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm:
     36        (-[WKNSURLAuthenticationChallengeSender continueWithoutCredentialForAuthenticationChallenge:]):
     37        * UIProcess/API/glib/WebKitAuthenticationRequest.cpp:
     38        (webkit_authentication_request_authenticate):
     39        * UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
     40        (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
     41        * UIProcess/Authentication/AuthenticationDecisionListener.cpp:
     42        (WebKit::AuthenticationDecisionListener::AuthenticationDecisionListener):
     43        (WebKit::AuthenticationDecisionListener::~AuthenticationDecisionListener):
     44        (WebKit::AuthenticationDecisionListener::useCredential):
     45        (WebKit::AuthenticationDecisionListener::cancel):
     46        (WebKit::AuthenticationDecisionListener::performDefaultHandling):
     47        (WebKit::AuthenticationDecisionListener::rejectProtectionSpaceAndContinue):
     48        * UIProcess/Authentication/AuthenticationDecisionListener.h:
     49        (WebKit::AuthenticationDecisionListener::create):
     50        * UIProcess/Cocoa/DownloadClient.mm:
     51        (WebKit::DownloadClient::didReceiveAuthenticationChallenge):
     52        * UIProcess/Cocoa/NavigationState.mm:
     53        (WebKit::NavigationState::NavigationClient::didReceiveAuthenticationChallenge):
     54        * WebKit.xcodeproj/project.pbxproj:
     55
    1562018-09-21  Chris Dumez  <cdumez@apple.com>
    257
  • trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp

    r235101 r236344  
    2727#include "Download.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "Connection.h"
  • trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp

    r235511 r236344  
    2727#include "NetworkCORSPreflightChecker.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "Logging.h"
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp

    r235511 r236344  
    2727#include "NetworkLoad.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "DownloadProxyMessages.h"
  • trunk/Source/WebKit/NetworkProcess/PingLoad.cpp

    r235511 r236344  
    2727#include "PingLoad.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "Logging.h"
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r235935 r236344  
    2727#import "NetworkDataTaskCocoa.h"
    2828
     29#import "AuthenticationChallengeDisposition.h"
    2930#import "AuthenticationManager.h"
    3031#import "Download.h"
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r236153 r236344  
    2727#import "NetworkSessionCocoa.h"
    2828
     29#import "AuthenticationChallengeDisposition.h"
    2930#import "AuthenticationManager.h"
    3031#import "DataReference.h"
  • trunk/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp

    r236156 r236344  
    2727#include "NetworkDataTaskCurl.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "NetworkSessionCurl.h"
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp

    r234896 r236344  
    2727#include "NetworkDataTaskSoup.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationManager.h"
    3031#include "DataReference.h"
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp

    r236153 r236344  
    135135}
    136136
    137 void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, const Credential& credential)
     137void AuthenticationManager::completeAuthenticationChallenge(uint64_t challengeID, AuthenticationChallengeDisposition disposition, WebCore::Credential&& credential)
    138138{
    139139    ASSERT(RunLoop::isMain());
    140140
    141     for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
    142         useCredentialForSingleChallenge(coalescedChallengeID, credential);
    143 }
    144 
    145 void AuthenticationManager::useCredentialForSingleChallenge(uint64_t challengeID, const Credential& credential)
    146 {
    147     auto challenge = m_challenges.take(challengeID);
    148     ASSERT(!challenge.challenge.isNull());
    149 
    150     auto completionHandler = WTFMove(challenge.completionHandler);
    151 
    152     if (completionHandler)
    153         completionHandler(AuthenticationChallengeDisposition::UseCredential, credential);
    154     else
    155         ASSERT_NOT_REACHED();
    156 }
    157 
    158 void AuthenticationManager::continueWithoutCredentialForChallenge(uint64_t challengeID)
    159 {
    160     ASSERT(RunLoop::isMain());
    161 
    162     for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
    163         continueWithoutCredentialForSingleChallenge(coalescedChallengeID);
    164 }
    165 
    166 void AuthenticationManager::continueWithoutCredentialForSingleChallenge(uint64_t challengeID)
    167 {
    168     auto challenge = m_challenges.take(challengeID);
    169     ASSERT(!challenge.challenge.isNull());
    170 
    171     if (challenge.completionHandler)
    172         challenge.completionHandler(AuthenticationChallengeDisposition::UseCredential, Credential());
    173     else
    174         ASSERT_NOT_REACHED();
    175 }
    176 
    177 void AuthenticationManager::cancelChallenge(uint64_t challengeID)
    178 {
    179     ASSERT(RunLoop::isMain());
    180 
    181     for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
    182         cancelSingleChallenge(coalescedChallengeID);
    183 }
    184 
    185 void AuthenticationManager::cancelSingleChallenge(uint64_t challengeID)
    186 {
    187     auto challenge = m_challenges.take(challengeID);
    188     ASSERT(!challenge.challenge.isNull());
    189 
    190     if (challenge.completionHandler)
    191         challenge.completionHandler(AuthenticationChallengeDisposition::Cancel, Credential());
    192     else
    193         ASSERT_NOT_REACHED();
    194 }
    195 
    196 void AuthenticationManager::performDefaultHandling(uint64_t challengeID)
    197 {
    198     ASSERT(RunLoop::isMain());
    199 
    200     for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
    201         performDefaultHandlingForSingleChallenge(coalescedChallengeID);
    202 }
    203 
    204 void AuthenticationManager::performDefaultHandlingForSingleChallenge(uint64_t challengeID)
    205 {
    206     auto challenge = m_challenges.take(challengeID);
    207     ASSERT(!challenge.challenge.isNull());
    208 
    209     if (challenge.completionHandler)
    210         challenge.completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, Credential());
    211     else
    212         ASSERT_NOT_REACHED();
    213 }
    214 
    215 void AuthenticationManager::rejectProtectionSpaceAndContinue(uint64_t challengeID)
    216 {
    217     ASSERT(RunLoop::isMain());
    218 
    219     for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID))
    220         rejectProtectionSpaceAndContinueForSingleChallenge(coalescedChallengeID);
    221 }
    222 
    223 void AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID)
    224 {
    225     auto challenge = m_challenges.take(challengeID);
    226     ASSERT(!challenge.challenge.isNull());
    227 
    228     if (challenge.completionHandler)
    229         challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, { });
    230     else
    231         ASSERT_NOT_REACHED();
     141    for (auto& coalescedChallengeID : coalesceChallengesMatching(challengeID)) {
     142        auto challenge = m_challenges.take(coalescedChallengeID);
     143        ASSERT(!challenge.challenge.isNull());
     144        challenge.completionHandler(disposition, credential);
     145    }
    232146}
    233147
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h

    r236153 r236344  
    5252class WebFrame;
    5353
    54 enum class AuthenticationChallengeDisposition {
    55     UseCredential,
    56     PerformDefaultHandling,
    57     Cancel,
    58     RejectProtectionSpaceAndContinue
    59 };
     54enum class AuthenticationChallengeDisposition;
    6055using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
    6156
     
    7065    void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    7166
    72     void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&);
    73     void continueWithoutCredentialForChallenge(uint64_t challengeID);
    74     void cancelChallenge(uint64_t challengeID);
    75     void performDefaultHandling(uint64_t challengeID);
    76     void rejectProtectionSpaceAndContinue(uint64_t challengeID);
     67    void completeAuthenticationChallenge(uint64_t challengeID, AuthenticationChallengeDisposition, WebCore::Credential&&);
    7768
    7869    uint64_t outstandingAuthenticationChallengeCount() const { return m_challenges.size(); }
     
    9687    bool shouldCoalesceChallenge(uint64_t pageID, uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
    9788
    98     void useCredentialForSingleChallenge(uint64_t challengeID, const WebCore::Credential&);
    99     void continueWithoutCredentialForSingleChallenge(uint64_t challengeID);
    100     void cancelSingleChallenge(uint64_t challengeID);
    101     void performDefaultHandlingForSingleChallenge(uint64_t challengeID);
    102     void rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID);
    103 
    10489    Vector<uint64_t> coalesceChallengesMatching(uint64_t challengeID) const;
    10590
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.messages.in

    r231916 r236344  
    2222
    2323messages -> AuthenticationManager {
    24     void UseCredentialForChallenge(uint64_t challengeID, WebCore::Credential credential);
    25     void ContinueWithoutCredentialForChallenge(uint64_t challengeID);
    26     void CancelChallenge(uint64_t challengeID);
    27     void PerformDefaultHandling(uint64_t challengeID);
    28     void RejectProtectionSpaceAndContinue(uint64_t challengeID);
     24    void CompleteAuthenticationChallenge(uint64_t challengeID, enum WebKit::AuthenticationChallengeDisposition disposition, WebCore::Credential credential);
    2925}
  • trunk/Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm

    r233340 r236344  
    2929#if HAVE(SEC_KEY_PROXY)
    3030
     31#import "AuthenticationChallengeDisposition.h"
    3132#import "ClientCertificateAuthenticationXPCConstants.h"
    3233#import "Connection.h"
     
    9798            return;
    9899
    99         weakThis->useCredentialForChallenge(challengeID, WebCore::Credential(adoptNS([[NSURLCredential alloc] initWithIdentity:identity.get() certificates:certificates persistence:(NSURLCredentialPersistence)persistence]).get()));
     100        weakThis->completeAuthenticationChallenge(challengeID, AuthenticationChallengeDisposition::UseCredential, WebCore::Credential(adoptNS([[NSURLCredential alloc] initWithIdentity:identity.get() certificates:certificates persistence:(NSURLCredentialPersistence)persistence]).get()));
    100101    });
    101102}
  • trunk/Source/WebKit/UIProcess/API/APINavigationClient.h

    r236232 r236344  
    2828#include "APIData.h"
    2929#include "APIString.h"
     30#include "AuthenticationChallengeDisposition.h"
    3031#include "AuthenticationChallengeProxy.h"
    3132#include "AuthenticationDecisionListener.h"
     
    8889    virtual void renderingProgressDidChange(WebKit::WebPageProxy&, WebCore::LayoutMilestones) { }
    8990
    90     virtual void didReceiveAuthenticationChallenge(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().performDefaultHandling(); }
     91    virtual void didReceiveAuthenticationChallenge(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling); }
    9192
    9293    // FIXME: These function should not be part of this client.
  • trunk/Source/WebKit/UIProcess/API/C/WKAuthenticationDecisionListener.cpp

    r236153 r236344  
    2727#include "WKAuthenticationDecisionListener.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationDecisionListener.h"
    3031#include "WKAPICast.h"
     
    4041void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential)
    4142{
    42     if (credential)
    43         toImpl(authenticationListener)->useCredential(toImpl(credential)->credential());
    44     else
    45         toImpl(authenticationListener)->useCredential(std::nullopt);
     43    toImpl(authenticationListener)->completeChallenge(AuthenticationChallengeDisposition::UseCredential, credential ? toImpl(credential)->credential() : WebCore::Credential());
    4644}
    4745
    4846void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener)
    4947{
    50     toImpl(authenticationListener)->cancel();
     48    toImpl(authenticationListener)->completeChallenge(AuthenticationChallengeDisposition::Cancel);
    5149}
    5250
    5351void WKAuthenticationDecisionListenerRejectProtectionSpaceAndContinue(WKAuthenticationDecisionListenerRef authenticationListener)
    5452{
    55     toImpl(authenticationListener)->rejectProtectionSpaceAndContinue();
     53    toImpl(authenticationListener)->completeChallenge(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue);
    5654}
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r236154 r236344  
    5050#include "APIWebsitePolicies.h"
    5151#include "APIWindowFeatures.h"
     52#include "AuthenticationChallengeDisposition.h"
    5253#include "AuthenticationChallengeProxy.h"
    5354#include "AuthenticationDecisionListener.h"
     
    21502151        {
    21512152            if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(WebProtectionSpace::create(authenticationChallenge.core().protectionSpace()).ptr()), m_client.base.clientInfo))
    2152                 return authenticationChallenge.listener().rejectProtectionSpaceAndContinue();
     2153                return authenticationChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue);
    21532154            if (!m_client.didReceiveAuthenticationChallenge)
    2154                 return authenticationChallenge.listener().performDefaultHandling();
     2155                return authenticationChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling);
    21552156            m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
    21562157        }
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm

    r236153 r236344  
    2929#if WK_API_ENABLED
    3030
     31#import "AuthenticationChallengeDisposition.h"
    3132#import "AuthenticationDecisionListener.h"
    3233#import "WebCertificateInfo.h"
     
    7172    checkChallenge(challenge);
    7273    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    73     webChallenge.listener().cancel();
     74    webChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::Cancel);
    7475}
    7576
     
    7879    checkChallenge(challenge);
    7980    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    80     webChallenge.listener().useCredential(std::nullopt);
     81    webChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::UseCredential);
    8182}
    8283
     
    8586    checkChallenge(challenge);
    8687    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    87     webChallenge.listener().useCredential(WebCore::Credential(credential));
     88    webChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::UseCredential, WebCore::Credential(credential));
    8889}
    8990
     
    9293    checkChallenge(challenge);
    9394    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    94     webChallenge.listener().performDefaultHandling();
     95    webChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling);
    9596}
    9697
     
    99100    checkChallenge(challenge);
    100101    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    101     webChallenge.listener().rejectProtectionSpaceAndContinue();
     102    webChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue);
    102103}
    103104
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp

    r236153 r236344  
    2121#include "WebKitAuthenticationRequest.h"
    2222
     23#include "AuthenticationChallengeDisposition.h"
    2324#include "AuthenticationDecisionListener.h"
    2425#include "WebCredential.h"
     
    316317    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
    317318
    318     if (credential)
    319         request->priv->authenticationChallenge->listener().useCredential(webkitCredentialGetCredential(credential));
    320     else
    321         request->priv->authenticationChallenge->listener().useCredential(std::nullopt);
     319    request->priv->authenticationChallenge->listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::UseCredential, credential ? webkitCredentialGetCredential(credential) : WebCore::Credential());
    322320
    323321    request->priv->handledRequest = true;
     
    337335    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
    338336
    339     request->priv->authenticationChallenge->listener().cancel();
     337    request->priv->authenticationChallenge->listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::Cancel);
    340338
    341339    g_signal_emit(request, signals[CANCELLED], 0);
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp

    r236153 r236344  
    4545AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, Ref<IPC::Connection>&& connection, WeakPtr<SecKeyProxyStore>&& secKeyProxyStore)
    4646    : m_coreAuthenticationChallenge(WTFMove(authenticationChallenge))
    47     , m_listener(AuthenticationDecisionListener::create([challengeID, connection = WTFMove(connection), secKeyProxyStore = WTFMove(secKeyProxyStore)](AuthenticationChallengeDisposition disposition, std::optional<WebCore::Credential>&& credential) {
    48         switch (disposition) {
    49         case AuthenticationChallengeDisposition::Cancel:
    50             connection->send(Messages::AuthenticationManager::CancelChallenge(challengeID), 0);
    51             break;
    52         case AuthenticationChallengeDisposition::PerformDefaultHandling:
    53             connection->send(Messages::AuthenticationManager::PerformDefaultHandling(challengeID), 0);
    54             break;
    55         case AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue:
    56             connection->send(Messages::AuthenticationManager::RejectProtectionSpaceAndContinue(challengeID), 0);
    57             break;
    58         case AuthenticationChallengeDisposition::UseCredential:
    59             if (!credential) {
    60                 connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
    61                 break;
    62             }
    63            
     47    , m_listener(AuthenticationDecisionListener::create([challengeID, connection = WTFMove(connection), secKeyProxyStore = WTFMove(secKeyProxyStore)](AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential) {
    6448#if HAVE(SEC_KEY_PROXY)
    65             if (secKeyProxyStore) {
    66                 secKeyProxyStore->initialize(*credential);
    67                 sendClientCertificateCredentialOverXpc(connection, *secKeyProxyStore, challengeID, *credential);
    68                 break;
    69             }
     49        if (secKeyProxyStore) {
     50            secKeyProxyStore->initialize(credential);
     51            sendClientCertificateCredentialOverXpc(connection, *secKeyProxyStore, challengeID, credential);
     52            return;
     53        }
    7054#endif
    71 
    72             connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, *credential), 0);
    73         }
     55        connection->send(Messages::AuthenticationManager::CompleteAuthenticationChallenge(challengeID, disposition, credential), 0);
    7456    }))
    7557{
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.cpp

    r236153 r236344  
    2727#include "AuthenticationDecisionListener.h"
    2828
     29#include "AuthenticationChallengeDisposition.h"
    2930#include "AuthenticationChallengeProxy.h"
    3031#include "AuthenticationManager.h"
     
    3738namespace WebKit {
    3839
    39 AuthenticationDecisionListener::AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
     40AuthenticationDecisionListener::AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>&& completionHandler)
    4041    : m_completionHandler(WTFMove(completionHandler))
    4142{
     
    4546{
    4647    if (m_completionHandler)
    47         m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
     48        m_completionHandler(AuthenticationChallengeDisposition::Cancel, { });
    4849}
    4950
    50 void AuthenticationDecisionListener::useCredential(std::optional<WebCore::Credential>&& credential)
     51void AuthenticationDecisionListener::completeChallenge(AuthenticationChallengeDisposition disposition, const WebCore::Credential& credential)
    5152{
    5253    if (m_completionHandler)
    53         m_completionHandler(AuthenticationChallengeDisposition::UseCredential, WTFMove(credential));
     54        m_completionHandler(disposition, credential);
    5455}
    5556
    56 void AuthenticationDecisionListener::cancel()
    57 {
    58     if (m_completionHandler)
    59         m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
    60 }
    61 
    62 void AuthenticationDecisionListener::performDefaultHandling()
    63 {
    64     if (m_completionHandler)
    65         m_completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, std::nullopt);
    66 }
    67 
    68 void AuthenticationDecisionListener::rejectProtectionSpaceAndContinue()
    69 {
    70     if (m_completionHandler)
    71         m_completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, std::nullopt);
    72 }
    73    
    7457} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.h

    r236153 r236344  
    3838class AuthenticationDecisionListener : public API::ObjectImpl<API::Object::Type::AuthenticationDecisionListener> {
    3939public:
    40     static Ref<AuthenticationDecisionListener> create(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
     40    static Ref<AuthenticationDecisionListener> create(CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>&& completionHandler)
    4141    {
    4242        return adoptRef(*new AuthenticationDecisionListener(WTFMove(completionHandler)));
     
    4444    ~AuthenticationDecisionListener();
    4545   
    46     void useCredential(std::optional<WebCore::Credential>&&);
    47     void cancel();
    48     void performDefaultHandling();
    49     void rejectProtectionSpaceAndContinue();
     46    void completeChallenge(AuthenticationChallengeDisposition, const WebCore::Credential& = { });
    5047
    5148private:
    52     explicit AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&&);
     49    explicit AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>&&);
    5350
    54     CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)> m_completionHandler;
     51    CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> m_completionHandler;
    5552};
    5653
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r236153 r236344  
    2929#if WK_API_ENABLED
    3030
     31#import "AuthenticationChallengeDisposition.h"
    3132#import "AuthenticationChallengeProxy.h"
    3233#import "AuthenticationDecisionListener.h"
     
    123124    // FIXME: System Preview needs code here.
    124125    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
    125         authenticationChallenge.listener().performDefaultHandling();
     126        authenticationChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling);
    126127        return;
    127128    }
     
    133134        switch (disposition) {
    134135        case NSURLSessionAuthChallengeUseCredential:
    135             if (credential)
    136                 authenticationChallenge->listener().useCredential(WebCore::Credential(credential));
    137             else
    138                 authenticationChallenge->listener().useCredential(std::nullopt);
     136            authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::UseCredential, credential ? WebCore::Credential(credential) : WebCore::Credential());
    139137            break;
    140138        case NSURLSessionAuthChallengePerformDefaultHandling:
    141             authenticationChallenge->listener().performDefaultHandling();
     139            authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling);
    142140            break;
    143141           
    144142        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
    145             authenticationChallenge->listener().cancel();
     143            authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::Cancel);
    146144            break;
    147145           
    148146        case NSURLSessionAuthChallengeRejectProtectionSpace:
    149             authenticationChallenge->listener().rejectProtectionSpaceAndContinue();
     147            authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue);
    150148            break;
    151149           
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r236154 r236344  
    3535#import "APIURL.h"
    3636#import "APIWebsiteDataStore.h"
     37#import "AuthenticationChallengeDisposition.h"
    3738#import "AuthenticationDecisionListener.h"
    3839#import "CompletionHandlerCallChecker.h"
     
    850851}
    851852
     853static AuthenticationChallengeDisposition toAuthenticationChallengeDisposition(NSURLSessionAuthChallengeDisposition disposition)
     854{
     855    switch (disposition) {
     856    case NSURLSessionAuthChallengeUseCredential:
     857        return AuthenticationChallengeDisposition::UseCredential;
     858    case NSURLSessionAuthChallengePerformDefaultHandling:
     859        return AuthenticationChallengeDisposition::PerformDefaultHandling;
     860    case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
     861        return AuthenticationChallengeDisposition::Cancel;
     862    case NSURLSessionAuthChallengeRejectProtectionSpace:
     863        return AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue;
     864    }
     865    [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
     866}
     867   
    852868void NavigationState::NavigationClient::didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy& authenticationChallenge)
    853869{
    854870    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
    855         return authenticationChallenge.listener().performDefaultHandling();
    856 
    857     auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
    858     if (!navigationDelegate)
    859         return authenticationChallenge.listener().performDefaultHandling();
     871        return authenticationChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling);
     872
     873    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
     874    if (!navigationDelegate)
     875        return authenticationChallenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling);
    860876
    861877    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
     
    864880            return;
    865881        checker->didCallCompletionHandler();
    866 
    867         switch (disposition) {
    868         case NSURLSessionAuthChallengeUseCredential:
    869             if (credential)
    870                 challenge->listener().useCredential(Credential(credential));
    871             else
    872                 challenge->listener().useCredential(std::nullopt);
    873             break;
    874         case NSURLSessionAuthChallengePerformDefaultHandling:
    875             challenge->listener().performDefaultHandling();
    876             break;
    877 
    878         case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
    879             challenge->listener().cancel();
    880             break;
    881 
    882         case NSURLSessionAuthChallengeRejectProtectionSpace:
    883             challenge->listener().rejectProtectionSpaceAndContinue();
    884             break;
    885 
    886         default:
    887             [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
    888         }
     882        challenge->listener().completeChallenge(toAuthenticationChallengeDisposition(disposition), Credential(credential));
    889883    }).get()];
    890884}
  • trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp

    r236153 r236344  
    2929#if ENABLE(SERVICE_WORKER)
    3030
     31#include "AuthenticationChallengeDisposition.h"
    3132#include "AuthenticationChallengeProxy.h"
    3233#include "AuthenticationDecisionListener.h"
     
    99100    if (protectionSpace.authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested && processPool().allowsAnySSLCertificateForServiceWorker()) {
    100101        auto credential = WebCore::Credential("accept server trust"_s, emptyString(), WebCore::CredentialPersistenceNone);
    101         challenge->listener().useCredential(credential);
     102        challenge->listener().completeChallenge(AuthenticationChallengeDisposition::UseCredential, credential);
    102103        return;
    103104    }
    104105    notImplemented();
    105     challenge->listener().performDefaultHandling();
     106    challenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling);
    106107}
    107108
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r236152 r236344  
    34443444                5CA98549210BEB5A0057EB6B /* SafeBrowsingResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingResult.h; sourceTree = "<group>"; };
    34453445                5CA9854B210BEB730057EB6B /* SafeBrowsingResultCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SafeBrowsingResultCocoa.mm; sourceTree = "<group>"; };
     3446                5CADDE0D2151AA010067D309 /* AuthenticationChallengeDisposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AuthenticationChallengeDisposition.h; path = Authentication/AuthenticationChallengeDisposition.h; sourceTree = "<group>"; };
    34463447                5CAFDE422130843500B1F7E1 /* _WKInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspector.h; sourceTree = "<group>"; };
    34473448                5CAFDE432130843600B1F7E1 /* _WKInspector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspector.mm; sourceTree = "<group>"; };
     
    65966597                        children = (
    65976598                                57B4B45C20B5048B00D4AD79 /* cocoa */,
     6599                                5CADDE0D2151AA010067D309 /* AuthenticationChallengeDisposition.h */,
    65986600                                518E8EF316B2091C00E91429 /* AuthenticationManager.cpp */,
    65996601                                518E8EF416B2091C00E91429 /* AuthenticationManager.h */,
Note: See TracChangeset for help on using the changeset viewer.