Changeset 234941 in webkit


Ignore:
Timestamp:
Aug 16, 2018 10:59:30 AM (6 years ago)
Author:
achristensen@apple.com
Message:

Stop using canAuthenticateAgainstProtectionSpace in modern WebKit
https://bugs.webkit.org/show_bug.cgi?id=188639

Reviewed by Youenn Fablet.

canAuthenticateAgainstProtectionSpace is an unnecessary step in the authentication process.
It is leftover from when it was necessary when we used NSURLConnection, which is only used in WebKitLegacy now.
Now it's just an extra IPC roundtrip asking if we should use NSURLSessionAuthChallengeRejectProtectionSpace
or if we are going to ask the API client. We can move this step into the C API for compatibility
with the 1 client that still uses it (not for long, see rdar://problem/43358403) and simplify and optimize
authentication.

  • NetworkProcess/Downloads/PendingDownload.cpp:

(WebKit::PendingDownload::canAuthenticateAgainstProtectionSpaceAsync): Deleted.

  • NetworkProcess/Downloads/PendingDownload.h:
  • NetworkProcess/NetworkCORSPreflightChecker.cpp:

(WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):

  • NetworkProcess/NetworkLoad.cpp:

(WebKit::NetworkLoad::~NetworkLoad):
(WebKit::NetworkLoad::didReceiveChallenge):
(WebKit::NetworkLoad::completeAuthenticationChallenge): Deleted.
(WebKit::NetworkLoad::continueCanAuthenticateAgainstProtectionSpace): Deleted.

  • NetworkProcess/NetworkLoad.h:
  • NetworkProcess/NetworkLoadClient.h:
  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::cancelDownload):
(WebKit::NetworkProcess::canAuthenticateAgainstProtectionSpace): Deleted.
(WebKit::NetworkProcess::continueCanAuthenticateAgainstProtectionSpace): Deleted.

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync): Deleted.

  • NetworkProcess/NetworkResourceLoader.h:
  • NetworkProcess/PreconnectTask.cpp:

(WebKit::PreconnectTask::canAuthenticateAgainstProtectionSpaceAsync): Deleted.

  • NetworkProcess/PreconnectTask.h:
  • NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:

(WebKit::NetworkCache::SpeculativeLoad::canAuthenticateAgainstProtectionSpaceAsync): Deleted.

  • NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):

  • Shared/Authentication/AuthenticationManager.h:
  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageNavigationClient):

  • UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
  • UIProcess/Cocoa/NavigationState.h:
  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::NavigationClient::didReceiveAuthenticationChallenge):
(WebKit::NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace): Deleted.

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::canAuthenticateAgainstProtectionSpace): Deleted.

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/Network/NetworkProcessProxy.messages.in:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::canAuthenticateAgainstProtectionSpace): Deleted.

  • UIProcess/WebPageProxy.h:
Location:
trunk/Source/WebKit
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r234940 r234941  
     12018-08-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Stop using canAuthenticateAgainstProtectionSpace in modern WebKit
     4        https://bugs.webkit.org/show_bug.cgi?id=188639
     5
     6        Reviewed by Youenn Fablet.
     7
     8        canAuthenticateAgainstProtectionSpace is an unnecessary step in the authentication process.
     9        It is leftover from when it was necessary when we used NSURLConnection, which is only used in WebKitLegacy now.
     10        Now it's just an extra IPC roundtrip asking if we should use NSURLSessionAuthChallengeRejectProtectionSpace
     11        or if we are going to ask the API client.  We can move this step into the C API for compatibility
     12        with the 1 client that still uses it (not for long, see rdar://problem/43358403) and simplify and optimize
     13        authentication.
     14
     15        * NetworkProcess/Downloads/PendingDownload.cpp:
     16        (WebKit::PendingDownload::canAuthenticateAgainstProtectionSpaceAsync): Deleted.
     17        * NetworkProcess/Downloads/PendingDownload.h:
     18        * NetworkProcess/NetworkCORSPreflightChecker.cpp:
     19        (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):
     20        * NetworkProcess/NetworkLoad.cpp:
     21        (WebKit::NetworkLoad::~NetworkLoad):
     22        (WebKit::NetworkLoad::didReceiveChallenge):
     23        (WebKit::NetworkLoad::completeAuthenticationChallenge): Deleted.
     24        (WebKit::NetworkLoad::continueCanAuthenticateAgainstProtectionSpace): Deleted.
     25        * NetworkProcess/NetworkLoad.h:
     26        * NetworkProcess/NetworkLoadClient.h:
     27        * NetworkProcess/NetworkProcess.cpp:
     28        (WebKit::NetworkProcess::cancelDownload):
     29        (WebKit::NetworkProcess::canAuthenticateAgainstProtectionSpace): Deleted.
     30        (WebKit::NetworkProcess::continueCanAuthenticateAgainstProtectionSpace): Deleted.
     31        * NetworkProcess/NetworkProcess.h:
     32        * NetworkProcess/NetworkProcess.messages.in:
     33        * NetworkProcess/NetworkResourceLoader.cpp:
     34        (WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync): Deleted.
     35        * NetworkProcess/NetworkResourceLoader.h:
     36        * NetworkProcess/PreconnectTask.cpp:
     37        (WebKit::PreconnectTask::canAuthenticateAgainstProtectionSpaceAsync): Deleted.
     38        * NetworkProcess/PreconnectTask.h:
     39        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
     40        (WebKit::NetworkCache::SpeculativeLoad::canAuthenticateAgainstProtectionSpaceAsync): Deleted.
     41        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.h:
     42        * Shared/Authentication/AuthenticationManager.cpp:
     43        (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
     44        * Shared/Authentication/AuthenticationManager.h:
     45        * UIProcess/API/C/WKPage.cpp:
     46        (WKPageSetPageNavigationClient):
     47        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
     48        * UIProcess/Cocoa/NavigationState.h:
     49        * UIProcess/Cocoa/NavigationState.mm:
     50        (WebKit::NavigationState::setNavigationDelegate):
     51        (WebKit::NavigationState::NavigationClient::didReceiveAuthenticationChallenge):
     52        (WebKit::NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace): Deleted.
     53        * UIProcess/Network/NetworkProcessProxy.cpp:
     54        (WebKit::NetworkProcessProxy::canAuthenticateAgainstProtectionSpace): Deleted.
     55        * UIProcess/Network/NetworkProcessProxy.h:
     56        * UIProcess/Network/NetworkProcessProxy.messages.in:
     57        * UIProcess/WebPageProxy.cpp:
     58        (WebKit::WebPageProxy::canAuthenticateAgainstProtectionSpace): Deleted.
     59        * UIProcess/WebPageProxy.h:
     60
    1612018-08-15  Jer Noble  <jer.noble@apple.com>
    262
  • trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp

    r227364 r234941  
    7777}
    7878
    79 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    80 void PendingDownload::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace& protectionSpace)
    81 {
    82     m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(true);
    83 }
    84 #endif
    85 
    8679void PendingDownload::didFailLoading(const WebCore::ResourceError& error)
    8780{
  • trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h

    r227364 r234941  
    5252    // NetworkLoadClient.
    5353    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override { }
    54 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    55     void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
    56 #endif
    5754    bool isSynchronous() const override { return false; }
    5855    bool isAllowedToAskUserForCredentials() const final { return m_isAllowedToAskUserForCredentials; }
  • trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp

    r234896 r234941  
    103103    }
    104104
    105 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    106     NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(challenge.protectionSpace(), m_parameters.pageID, m_parameters.frameID, [this, weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler), challenge = WTFMove(challenge)] (bool canAuthenticate) mutable {
    107         if (!canAuthenticate)
    108             return completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
    109         NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.pageID, m_parameters.frameID, challenge, WTFMove(completionHandler));
    110     });
    111 #else
    112105    NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.pageID, m_parameters.frameID, challenge, WTFMove(completionHandler));
    113 #endif
    114106}
    115107
  • trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h

    r234896 r234941  
    4040namespace WebKit {
    4141
    42 class NetworkCORSPreflightChecker final : private NetworkDataTaskClient, public CanMakeWeakPtr<NetworkCORSPreflightChecker> {
     42class NetworkCORSPreflightChecker final : private NetworkDataTaskClient {
    4343    WTF_MAKE_FAST_ALLOCATED;
    4444public:
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp

    r234896 r234941  
    4343#if PLATFORM(COCOA)
    4444#include "NetworkDataTaskCocoa.h"
     45#include "NetworkSessionCocoa.h"
    4546#endif
    4647
     
    122123    if (m_responseCompletionHandler)
    123124        m_responseCompletionHandler(PolicyAction::Ignore);
    124 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    125     if (m_challengeCompletionHandler)
    126         m_challengeCompletionHandler(AuthenticationChallengeDisposition::Cancel, { });
    127 #endif
    128125    if (m_task)
    129126        m_task->clearClient();
     
    257254void NetworkLoad::didReceiveChallenge(AuthenticationChallenge&& challenge, ChallengeCompletionHandler&& completionHandler)
    258255{
    259     m_challenge = challenge;
    260 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    261     m_challengeCompletionHandler = WTFMove(completionHandler);
    262     m_client.get().canAuthenticateAgainstProtectionSpaceAsync(challenge.protectionSpace());
    263 #else
    264     completeAuthenticationChallenge(WTFMove(completionHandler));
    265 #endif
    266 }
    267 
    268 void NetworkLoad::completeAuthenticationChallenge(ChallengeCompletionHandler&& completionHandler)
    269 {
    270     auto scheme = m_challenge->protectionSpace().authenticationScheme();
     256    auto scheme = challenge.protectionSpace().authenticationScheme();
    271257    bool isTLSHandshake = scheme == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested
    272258        || scheme == ProtectionSpaceAuthenticationSchemeClientCertificateRequested;
     
    277263    }
    278264
    279     if (!m_task)
    280         return;
    281 
     265#if PLATFORM(COCOA)
     266    if (scheme == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested
     267        && NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost(challenge))
     268        return completionHandler(AuthenticationChallengeDisposition::UseCredential, serverTrustCredential(challenge));
     269#endif
     270   
    282271    if (auto* pendingDownload = m_task->pendingDownload())
    283         NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*pendingDownload, *m_challenge, WTFMove(completionHandler));
     272        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*pendingDownload, challenge, WTFMove(completionHandler));
    284273    else
    285         NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.webPageID, m_parameters.webFrameID, *m_challenge, WTFMove(completionHandler));
    286 }
    287 
    288 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    289 void NetworkLoad::continueCanAuthenticateAgainstProtectionSpace(bool result)
    290 {
    291     if (!m_challengeCompletionHandler) {
    292         ASSERT_NOT_REACHED();
    293         return;
    294     }
    295 
    296     auto completionHandler = std::exchange(m_challengeCompletionHandler, nullptr);
    297     if (!result) {
    298         if (NetworkSession::allowsSpecificHTTPSCertificateForHost(*m_challenge))
    299             completionHandler(AuthenticationChallengeDisposition::UseCredential, serverTrustCredential(*m_challenge));
    300         else
    301             completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
    302         return;
    303     }
    304 
    305     completeAuthenticationChallenge(WTFMove(completionHandler));
    306 }
    307 #endif
     274        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.webPageID, m_parameters.webFrameID, challenge, WTFMove(completionHandler));
     275}
    308276
    309277void NetworkLoad::didReceiveResponseNetworkSession(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.h

    r234896 r234941  
    7070    bool shouldCaptureExtraNetworkLoadMetrics() const final;
    7171
    72 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    73     void continueCanAuthenticateAgainstProtectionSpace(bool);
    74 #endif
    75 
    7672    String description() const;
    7773
     
    9692    void throttleDelayCompleted();
    9793
    98     void completeAuthenticationChallenge(ChallengeCompletionHandler&&);
    99 
    10094    std::reference_wrapper<NetworkLoadClient> m_client;
    10195    const NetworkLoadParameters m_parameters;
    10296    CompletionHandler<void(WebCore::ResourceRequest&&)> m_redirectCompletionHandler;
    10397    RefPtr<NetworkDataTask> m_task;
    104     std::optional<WebCore::AuthenticationChallenge> m_challenge;
    105 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    106     ChallengeCompletionHandler m_challengeCompletionHandler;
    107 #endif
    10898    ResponseCompletionHandler m_responseCompletionHandler;
    10999   
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadClient.h

    r228231 r234941  
    4848
    4949    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
    50 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    51     virtual void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) = 0;
    52 #endif
    5350    virtual void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) = 0;
    5451    enum class ShouldContinueDidReceiveResponse { No, Yes };
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r234896 r234941  
    668668    downloadManager().cancelDownload(downloadID);
    669669}
    670    
    671 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    672 void NetworkProcess::canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace& protectionSpace, uint64_t pageID, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler)
    673 {
    674     static uint64_t lastCompletionHandlerID = 0;
    675     uint64_t completionHandlerID = ++lastCompletionHandlerID;
    676     m_canAuthenticateAgainstProtectionSpaceCompletionHandlers.add(completionHandlerID, WTFMove(completionHandler));
    677     parentProcessConnection()->send(Messages::NetworkProcessProxy::CanAuthenticateAgainstProtectionSpace(completionHandlerID, pageID, frameID, protectionSpace), 0);
    678 }
    679 
    680 void NetworkProcess::continueCanAuthenticateAgainstProtectionSpace(uint64_t completionHandlerID, bool canAuthenticate)
    681 {
    682     if (auto completionHandler = m_canAuthenticateAgainstProtectionSpaceCompletionHandlers.take(completionHandlerID)) {
    683         completionHandler(canAuthenticate);
    684         return;
    685     }
    686     ASSERT_NOT_REACHED();
    687 }
    688 
    689 #endif
    690670
    691671void NetworkProcess::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r234910 r234941  
    124124    void findPendingDownloadLocation(NetworkDataTask&, ResponseCompletionHandler&&, const WebCore::ResourceResponse&);
    125125
    126 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    127     void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&, uint64_t pageID, uint64_t frameID, CompletionHandler<void(bool)>&&);
    128 #endif
    129 
    130126    void prefetchDNS(const String&);
    131127
     
    223219    void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&);
    224220    void cancelDownload(DownloadID);
    225 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    226     void continueCanAuthenticateAgainstProtectionSpace(uint64_t completionHandlerID, bool canAuthenticate);
    227 #endif
    228221    void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
    229222    void continueDecidePendingDownloadDestination(DownloadID, String destination, SandboxExtension::Handle&&, bool allowOverwrite);
     
    284277
    285278    HashMap<uint64_t, Function<void()>> m_sandboxExtensionForBlobsCompletionHandlers;
    286 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    287     HashMap<uint64_t, CompletionHandler<void(bool)>> m_canAuthenticateAgainstProtectionSpaceCompletionHandlers;
    288 #endif
    289279    HashSet<PAL::SessionID> m_sessionsControlledByAutomation;
    290280
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r234440 r234941  
    4747    CancelDownload(WebKit::DownloadID downloadID)
    4848
    49 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    50     ContinueCanAuthenticateAgainstProtectionSpace(uint64_t loaderID, bool canAuthenticate)
    51 #endif
    5249    ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
    5350    ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite)
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r234896 r234941  
    936936}
    937937
    938 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    939 void NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(const ProtectionSpace& protectionSpace)
    940 {
    941     NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(protectionSpace, pageID(), frameID(), [this, protectedThis = makeRef(*this)] (bool result) {
    942         if (m_networkLoad)
    943             m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(result);
    944     });
    945 }
    946 #endif
    947 
    948938bool NetworkResourceLoader::isAlwaysOnLoggingAllowed() const
    949939{
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h

    r234896 r234941  
    9595    // NetworkLoadClient.
    9696    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
    97 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    98     void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
    99 #endif
    10097    bool isSynchronous() const override;
    10198    bool isAllowedToAskUserForCredentials() const override { return m_isAllowedToAskUserForCredentials; }
  • trunk/Source/WebKit/NetworkProcess/PreconnectTask.cpp

    r234896 r234941  
    9797}
    9898
    99 void PreconnectTask::canAuthenticateAgainstProtectionSpaceAsync(const ProtectionSpace& protectionSpace)
    100 {
    101     if (!pageID()) {
    102         // The preconnect was started by the UIProcess.
    103         m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(false);
    104         return;
    105     }
    106     NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(protectionSpace, pageID(), frameID(), [weakThis = makeWeakPtr(this)] (bool result) {
    107         if (weakThis)
    108             weakThis->m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(result);
    109     });
    110 }
    111 
    11299void PreconnectTask::didFinish(const ResourceError& error)
    113100{
  • trunk/Source/WebKit/NetworkProcess/PreconnectTask.h

    r234896 r234941  
    3838class NetworkLoadParameters;
    3939
    40 class PreconnectTask final : public NetworkLoadClient, public CanMakeWeakPtr<PreconnectTask> {
     40class PreconnectTask final : public NetworkLoadClient {
    4141public:
    4242    explicit PreconnectTask(NetworkLoadParameters&&, WTF::CompletionHandler<void(const WebCore::ResourceError&)>&& completionHandler = { });
     
    5151    bool isAllowedToAskUserForCredentials() const final { return false; }
    5252    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final;
    53     void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) final;
    5453    void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
    5554    ShouldContinueDidReceiveResponse didReceiveResponse(WebCore::ResourceResponse&&) final;
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp

    r233668 r234941  
    123123}
    124124
    125 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    126 void SpeculativeLoad::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&)
    127 {
    128     m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(false);
    129 }
    130 #endif
    131 
    132125void SpeculativeLoad::didFailLoading(const ResourceError&)
    133126{
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h

    r224134 r234941  
    5454    // NetworkLoadClient.
    5555    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override { }
    56 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    57     void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
    58 #endif
    5956    bool isSynchronous() const override { return false; }
    6057    bool isAllowedToAskUserForCredentials() const final { return false; }
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp

    r231916 r234941  
    112112void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
    113113{
    114     ASSERT(pageID);
    115     ASSERT(frameID);
     114    if (!pageID || !frameID) // Initiated by SpeculativeLoadManager
     115        return completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
    116116
    117117    uint64_t challengeID = addChallengeToChallengeMap({ pageID, authenticationChallenge, WTFMove(completionHandler) });
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h

    r233654 r234941  
    6969    void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    7070    void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    71 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    72     void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
    73 #endif
    7471
    7572    void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&);
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r234168 r234941  
    22982298        void didReceiveAuthenticationChallenge(WebPageProxy& page, AuthenticationChallengeProxy& authenticationChallenge) override
    22992299        {
     2300            if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(authenticationChallenge.protectionSpace()), m_client.base.clientInfo))
     2301                return authenticationChallenge.rejectProtectionSpaceAndContinue();
    23002302            if (!m_client.didReceiveAuthenticationChallenge)
    2301                 return;
     2303                return authenticationChallenge.rejectProtectionSpaceAndContinue();
    23022304            m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
    23032305        }
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h

    r234903 r234941  
    7676- (void)_webView:(WKWebView *)webView renderingProgressDidChange:(_WKRenderingProgressEvents)progressEvents;
    7777
    78 - (void)_webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge WK_API_DEPRECATED_WITH_REPLACEMENT("webView:didReceiveAuthenticationChallenge:completionHandler:", macosx(10.10, 10.13.4), ios(8.0, 11.3));
    79 
    8078- (void)_webViewWebProcessDidCrash:(WKWebView *)webView;
    8179- (void)_webViewWebProcessDidBecomeResponsive:(WKWebView *)webView;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h

    r234903 r234941  
    109109        void renderingProgressDidChange(WebPageProxy&, WebCore::LayoutMilestones) override;
    110110
    111         bool canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace*) override;
    112111        void didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy&) override;
    113112        bool processDidTerminate(WebPageProxy&, ProcessTerminationReason) override;
     
    208207        bool webViewWebContentProcessDidTerminate : 1;
    209208        bool webViewWebContentProcessDidTerminateWithReason : 1;
    210         bool webViewDidReceiveAuthenticationChallenge : 1;
    211209        bool webViewWebProcessDidCrash : 1;
    212210        bool webViewWebProcessDidBecomeResponsive : 1;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r234903 r234941  
    165165    m_navigationDelegateMethods.webViewWebContentProcessDidTerminate = [delegate respondsToSelector:@selector(webViewWebContentProcessDidTerminate:)];
    166166    m_navigationDelegateMethods.webViewWebContentProcessDidTerminateWithReason = [delegate respondsToSelector:@selector(_webView:webContentProcessDidTerminateWithReason:)];
    167     m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge = [delegate respondsToSelector:@selector(_webView:didReceiveAuthenticationChallenge:)];
    168167    m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
    169168    m_navigationDelegateMethods.webViewWebProcessDidBecomeResponsive = [delegate respondsToSelector:@selector(_webViewWebProcessDidBecomeResponsive:)];
     
    870869}
    871870
    872 bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace* protectionSpace)
    873 {
    874     return !!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler;
    875 }
    876 
    877871void NavigationState::NavigationClient::didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy& authenticationChallenge)
    878872{
    879     if (m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler) {
    880         auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
    881         if (!navigationDelegate) {
    882             authenticationChallenge.listener()->performDefaultHandling();
     873    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
     874        return authenticationChallenge.rejectProtectionSpaceAndContinue();
     875
     876    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
     877    if (!navigationDelegate)
     878        return authenticationChallenge.performDefaultHandling();
     879
     880    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
     881    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge) completionHandler:BlockPtr<void(NSURLSessionAuthChallengeDisposition, NSURLCredential *)>::fromCallable([challenge = makeRef(authenticationChallenge), checker = WTFMove(checker)](NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) {
     882        if (checker->completionHandlerHasBeenCalled())
    883883            return;
     884        checker->didCallCompletionHandler();
     885
     886        switch (disposition) {
     887        case NSURLSessionAuthChallengeUseCredential: {
     888            RefPtr<WebCredential> webCredential;
     889            if (credential)
     890                webCredential = WebCredential::create(WebCore::Credential(credential));
     891
     892            challenge->useCredential(webCredential.get());
     893            break;
    884894        }
    885895
    886         auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
    887         [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge) completionHandler:BlockPtr<void(NSURLSessionAuthChallengeDisposition, NSURLCredential *)>::fromCallable([challenge = makeRef(authenticationChallenge), checker = WTFMove(checker)](NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) {
    888             if (checker->completionHandlerHasBeenCalled())
    889                 return;
    890             checker->didCallCompletionHandler();
    891 
    892             switch (disposition) {
    893             case NSURLSessionAuthChallengeUseCredential: {
    894                 RefPtr<WebCredential> webCredential;
    895                 if (credential)
    896                     webCredential = WebCredential::create(WebCore::Credential(credential));
    897 
    898                 challenge->listener()->useCredential(webCredential.get());
    899                 break;
    900             }
    901 
    902             case NSURLSessionAuthChallengePerformDefaultHandling:
    903                 challenge->listener()->performDefaultHandling();
    904                 break;
    905 
    906             case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
    907                 challenge->listener()->cancel();
    908                 break;
    909 
    910             case NSURLSessionAuthChallengeRejectProtectionSpace:
    911                 challenge->listener()->rejectProtectionSpaceAndContinue();
    912                 break;
    913 
    914             default:
    915                 [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
    916             }
    917         }).get()];
    918         return;
    919     }
    920 
    921     if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge)
    922         return;
    923 
    924     auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
    925     if (!navigationDelegate)
    926         return;
    927 
    928 #pragma clang diagnostic push
    929 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    930     [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge)];
    931 #pragma clang diagnostic pop
     896        case NSURLSessionAuthChallengePerformDefaultHandling:
     897            challenge->performDefaultHandling();
     898            break;
     899
     900        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
     901            challenge->cancel();
     902            break;
     903
     904        case NSURLSessionAuthChallengeRejectProtectionSpace:
     905            challenge->rejectProtectionSpaceAndContinue();
     906            break;
     907
     908        default:
     909            [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
     910        }
     911    }).get()];
    932912}
    933913
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r234440 r234941  
    400400}
    401401
    402 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    403 void NetworkProcessProxy::canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace& protectionSpace)
    404 {
    405     // NetworkProcess state cannot asynchronously be kept in sync with these objects
    406     // like we expect WebProcess <-> UIProcess state to be kept in sync.
    407     // So there's no guarantee the messaged WebPageProxy or WebFrameProxy exist here in the UIProcess.
    408     // We need to validate both the page and the frame up front.
    409     if (auto* page = WebProcessProxy::webPage(pageID)) {
    410         if (page->process().webFrame(frameID)) {
    411             page->canAuthenticateAgainstProtectionSpace(loaderID, frameID, protectionSpace);
    412             return;
    413         }
    414 #if ENABLE(SERVICE_WORKER)
    415     } else if (m_processPool.serviceWorkerProcessProxyFromPageID(pageID)) {
    416         send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, true), 0);
    417         return;
    418 #endif
    419     }
    420     // In the case where we will not be able to reply to this message with a client reply,
    421     // we should message back a default to the Networking process.
    422     send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, false), 0);
    423 }
    424 #endif
    425 
    426402#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    427403void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r234440 r234941  
    144144    void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
    145145    void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
    146 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    147     void canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace&);
    148 #endif
    149146#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    150147    void didUpdateBlockCookies(uint64_t contextId);
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r234440 r234941  
    4444    LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum WebCore::ShouldSample shouldSample)
    4545
    46 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    47     CanAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, WebCore::ProtectionSpace protectionSpace)
    48 #endif
    4946#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    5047    DidUpdateBlockCookies(uint64_t callbackId)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r234920 r234941  
    63906390#endif
    63916391
    6392 void WebPageProxy::canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t frameID, const ProtectionSpace& coreProtectionSpace)
    6393 {
    6394 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    6395     WebFrameProxy* frame = m_process->webFrame(frameID);
    6396     MESSAGE_CHECK(frame);
    6397 
    6398     RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
    6399 
    6400     bool canAuthenticate;
    6401     if (m_navigationClient)
    6402         canAuthenticate = m_navigationClient->canAuthenticateAgainstProtectionSpace(*this, protectionSpace.get());
    6403     else
    6404         canAuthenticate = m_loaderClient->canAuthenticateAgainstProtectionSpaceInFrame(*this, *frame, protectionSpace.get());
    6405 
    6406     m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, canAuthenticate));
    6407 #endif
    6408 }
    6409 
    64106392void WebPageProxy::didReceiveAuthenticationChallengeProxy(uint64_t frameID, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
    64116393{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r234920 r234941  
    12911291    bool isAlwaysOnLoggingAllowed() const;
    12921292
    1293     void canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t frameID, const WebCore::ProtectionSpace&);
    1294 
    12951293#if ENABLE(GAMEPAD)
    12961294    void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
Note: See TracChangeset for help on using the changeset viewer.