⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249277 in webkit


Ignore:
Timestamp:
Aug 29, 2019, 9:19:20 AM (7 years ago)
Author:
youenn@apple.com
Message:

Use WebPageProxy callbacks in case of authentication challenge received from Service Worker
https://bugs.webkit.org/show_bug.cgi?id=201177

Reviewed by Alex Christensen.

Source/WebKit:

Send topOrigin for every possible load to NetworkProcess.
Send topOrigin as part of authentication challenge to UIProcess.

If there is no corresponding page for the pageID, try getting a page
related to the service worker using the topOrigin and send the challenge to it.

  • NetworkProcess/NetworkCORSPreflightChecker.cpp:

(WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):

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

(WebKit::NetworkLoad::didReceiveChallenge):

  • NetworkProcess/NetworkLoadChecker.cpp:

(WebKit::NetworkLoadChecker::NetworkLoadChecker):
(WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):

  • NetworkProcess/NetworkLoadChecker.h:
  • NetworkProcess/NetworkLoadParameters.h:
  • NetworkProcess/NetworkResourceLoadParameters.cpp:

(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):

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

(WebKit::m_shouldCaptureExtraNetworkLoadMetrics):

  • NetworkProcess/PingLoad.cpp:

(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::didReceiveChallenge):

  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):

  • Shared/Authentication/AuthenticationManager.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::processAuthenticationChallenge):
(WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):

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

(WebKit::WebPageProxy::didReceiveAuthenticationChallengeProxy):

  • UIProcess/WebPageProxy.h:
  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):

LayoutTests:

  • http/wpt/service-workers/server-trust-evaluation.https.html:
Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249272 r249277  
     12019-08-29  Youenn Fablet  <youenn@apple.com>
     2
     3        Use WebPageProxy callbacks in case of authentication challenge received from Service Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=201177
     5
     6        Reviewed by Alex Christensen.
     7
     8        * http/wpt/service-workers/server-trust-evaluation.https.html:
     9
    1102019-08-29  Rob Buis  <rbuis@igalia.com>
    211
  • trunk/LayoutTests/http/wpt/service-workers/server-trust-evaluation.https.html

    r249096 r249277  
    1212promise_test(async (test) => {
    1313    if (window.testRunner) {
    14         window.testRunner.terminateNetworkProcess();
     14        testRunner.terminateNetworkProcess();
    1515        await fetch("").then(() => { }, () => { });
    1616    }
     
    3333
    3434promise_test(async (test) => {
    35     if (window.testRunner)
    36         window.testRunner.setAllowsAnySSLCertificate(false);
     35    let count;
     36    if (window.testRunner) {
     37        testRunner.setAllowsAnySSLCertificate(false);
     38        count = testRunner.serverTrustEvaluationCallbackCallsCount;
     39    }
    3740
    3841    iframe = await with_iframe("resources/iframe1.html");
    3942    assert_true(iframe.contentWindow.document.body.innerHTML.trim().indexOf("Load failed: ") !== -1);
    4043    iframe.remove();
     44
     45    if (window.testRunner)
     46        assert_equals(testRunner.serverTrustEvaluationCallbackCallsCount, count + 1);
     47
    4148}, "Service worker load should fail");
    4249
    4350promise_test(async (test) => {
    44     if (window.testRunner)
     51    let count;
     52    if (window.testRunner) {
    4553        window.testRunner.setAllowsAnySSLCertificate(true);
     54        count = testRunner.serverTrustEvaluationCallbackCallsCount;
     55    }
    4656
    4757    iframe = await with_iframe("resources/iframe2.html");
    4858    assert_true(iframe.contentWindow.document.body.innerHTML.trim().indexOf("PASS") !== -1);
    4959    iframe.remove();
     60
     61    if (window.testRunner)
     62        assert_equals(testRunner.serverTrustEvaluationCallbackCallsCount, count + 1);
    5063}, "Service worker load should succeed");
    5164</script>
  • trunk/Source/WebKit/ChangeLog

    r249275 r249277  
     12019-08-29  Youenn Fablet  <youenn@apple.com>
     2
     3        Use WebPageProxy callbacks in case of authentication challenge received from Service Worker
     4        https://bugs.webkit.org/show_bug.cgi?id=201177
     5
     6        Reviewed by Alex Christensen.
     7
     8        Send topOrigin for every possible load to NetworkProcess.
     9        Send topOrigin as part of authentication challenge to UIProcess.
     10
     11        If there is no corresponding page for the pageID, try getting a page
     12        related to the service worker using the topOrigin and send the challenge to it.
     13
     14        * NetworkProcess/NetworkCORSPreflightChecker.cpp:
     15        (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge):
     16        * NetworkProcess/NetworkCORSPreflightChecker.h:
     17        * NetworkProcess/NetworkLoad.cpp:
     18        (WebKit::NetworkLoad::didReceiveChallenge):
     19        * NetworkProcess/NetworkLoadChecker.cpp:
     20        (WebKit::NetworkLoadChecker::NetworkLoadChecker):
     21        (WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):
     22        * NetworkProcess/NetworkLoadChecker.h:
     23        * NetworkProcess/NetworkLoadParameters.h:
     24        * NetworkProcess/NetworkResourceLoadParameters.cpp:
     25        (WebKit::NetworkResourceLoadParameters::encode const):
     26        (WebKit::NetworkResourceLoadParameters::decode):
     27        * NetworkProcess/NetworkResourceLoadParameters.h:
     28        * NetworkProcess/NetworkResourceLoader.cpp:
     29        (WebKit::m_shouldCaptureExtraNetworkLoadMetrics):
     30        * NetworkProcess/PingLoad.cpp:
     31        (WebKit::PingLoad::PingLoad):
     32        (WebKit::PingLoad::didReceiveChallenge):
     33        * Shared/Authentication/AuthenticationManager.cpp:
     34        (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
     35        * Shared/Authentication/AuthenticationManager.h:
     36        * UIProcess/Network/NetworkProcessProxy.cpp:
     37        (WebKit::NetworkProcessProxy::processAuthenticationChallenge):
     38        (WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):
     39        * UIProcess/Network/NetworkProcessProxy.h:
     40        * UIProcess/Network/NetworkProcessProxy.messages.in:
     41        * UIProcess/WebPageProxy.cpp:
     42        (WebKit::WebPageProxy::didReceiveAuthenticationChallengeProxy):
     43        * UIProcess/WebPageProxy.h:
     44        * WebProcess/Network/WebLoaderStrategy.cpp:
     45        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
     46        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
     47        (WebKit::WebLoaderStrategy::startPingLoad):
     48
    1492019-08-29  Chris Dumez  <cdumez@apple.com>
    250
  • trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp

    r249096 r249277  
    102102    }
    103103
    104     m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_parameters.sessionID, m_parameters.pageID, m_parameters.frameID, challenge, WTFMove(completionHandler));
     104    m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_parameters.sessionID, m_parameters.pageID, m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, WTFMove(completionHandler));
    105105}
    106106
  • trunk/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h

    r248783 r249277  
    4949        WebCore::ResourceRequest originalRequest;
    5050        Ref<WebCore::SecurityOrigin> sourceOrigin;
     51        RefPtr<WebCore::SecurityOrigin> topOrigin;
    5152        String referrer;
    5253        String userAgent;
    5354        PAL::SessionID sessionID;
    5455        WebCore::PageIdentifier pageID;
    55         WebCore::FrameIdentifier frameID;
    5656        WebCore::StoredCredentialsPolicy storedCredentialsPolicy;
    5757    };
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp

    r249096 r249277  
    202202        m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(*pendingDownload, challenge, WTFMove(completionHandler));
    203203    else
    204         m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_task->sessionID(), m_parameters.webPageID, m_parameters.webFrameID, challenge, WTFMove(completionHandler));
     204        m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_task->sessionID(), m_parameters.webPageID, m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, WTFMove(completionHandler));
    205205}
    206206
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp

    r248846 r249277  
    4949}
    5050
    51 NetworkLoadChecker::NetworkLoadChecker(NetworkProcess& networkProcess, FetchOptions&& options, PAL::SessionID sessionID, PageIdentifier pageID, FrameIdentifier frameID, HTTPHeaderMap&& originalRequestHeaders, URL&& url, RefPtr<SecurityOrigin>&& sourceOrigin, PreflightPolicy preflightPolicy, String&& referrer, bool isHTTPSUpgradeEnabled, bool shouldCaptureExtraNetworkLoadMetrics, LoadType requestLoadType)
     51NetworkLoadChecker::NetworkLoadChecker(NetworkProcess& networkProcess, FetchOptions&& options, PAL::SessionID sessionID, PageIdentifier pageID, FrameIdentifier frameID, HTTPHeaderMap&& originalRequestHeaders, URL&& url, RefPtr<SecurityOrigin>&& sourceOrigin, RefPtr<SecurityOrigin>&& topOrigin, PreflightPolicy preflightPolicy, String&& referrer, bool isHTTPSUpgradeEnabled, bool shouldCaptureExtraNetworkLoadMetrics, LoadType requestLoadType)
    5252    : m_options(WTFMove(options))
    5353    , m_sessionID(sessionID)
     
    5858    , m_url(WTFMove(url))
    5959    , m_origin(WTFMove(sourceOrigin))
     60    , m_topOrigin(WTFMove(topOrigin))
    6061    , m_preflightPolicy(preflightPolicy)
    6162    , m_referrer(WTFMove(referrer))
     
    407408        WTFMove(requestForPreflight),
    408409        *m_origin,
     410        m_topOrigin,
    409411        request.httpReferrer(),
    410412        request.httpUserAgent(),
    411413        m_sessionID,
    412414        m_pageID,
    413         m_frameID,
    414415        m_storedCredentialsPolicy
    415416    };
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h

    r249096 r249277  
    5757    enum class LoadType : bool { MainFrame, Other };
    5858
    59     NetworkLoadChecker(NetworkProcess&, WebCore::FetchOptions&&, PAL::SessionID, WebCore::PageIdentifier, WebCore::FrameIdentifier, WebCore::HTTPHeaderMap&&, URL&&, RefPtr<WebCore::SecurityOrigin>&&, WebCore::PreflightPolicy, String&& referrer, bool isHTTPSUpgradeEnabled = false, bool shouldCaptureExtraNetworkLoadMetrics = false, LoadType requestLoadType = LoadType::Other);
     59    NetworkLoadChecker(NetworkProcess&, WebCore::FetchOptions&&, PAL::SessionID, WebCore::PageIdentifier, WebCore::FrameIdentifier, WebCore::HTTPHeaderMap&&, URL&&, RefPtr<WebCore::SecurityOrigin>&&, RefPtr<WebCore::SecurityOrigin>&& topOrigin, WebCore::PreflightPolicy, String&& referrer, bool isHTTPSUpgradeEnabled = false, bool shouldCaptureExtraNetworkLoadMetrics = false, LoadType requestLoadType = LoadType::Other);
    6060    ~NetworkLoadChecker();
    6161
     
    136136    URL m_url;
    137137    RefPtr<WebCore::SecurityOrigin> m_origin;
     138    RefPtr<WebCore::SecurityOrigin> m_topOrigin;
    138139    Optional<WebCore::ContentSecurityPolicyResponseHeaders> m_cspResponseHeaders;
    139140#if ENABLE(CONTENT_EXTENSIONS)
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h

    r248713 r249277  
    3232#include <WebCore/ResourceLoaderOptions.h>
    3333#include <WebCore/ResourceRequest.h>
     34#include <WebCore/SecurityOrigin.h>
    3435#include <pal/SessionID.h>
    3536#include <wtf/ProcessID.h>
     
    4950    WebCore::PageIdentifier webPageID;
    5051    WebCore::FrameIdentifier webFrameID;
     52    RefPtr<WebCore::SecurityOrigin> topOrigin;
    5153    WTF::ProcessID parentPID { 0 };
    5254    WebCore::ResourceRequest request;
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp

    r248677 r249277  
    8585    if (sourceOrigin)
    8686        encoder << *sourceOrigin;
     87    encoder << static_cast<bool>(topOrigin);
     88    if (sourceOrigin)
     89        encoder << *topOrigin;
    8790    encoder << options;
    8891    encoder << cspResponseHeaders;
     
    190193    }
    191194
     195    bool hasTopOrigin;
     196    if (!decoder.decode(hasTopOrigin))
     197        return WTF::nullopt;
     198    if (hasTopOrigin) {
     199        result.topOrigin = SecurityOrigin::decode(decoder);
     200        if (!result.topOrigin)
     201            return WTF::nullopt;
     202    }
     203
    192204    Optional<FetchOptions> options;
    193205    decoder >> options;
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h

    r248677 r249277  
    3131#include <WebCore/ContentSecurityPolicyResponseHeaders.h>
    3232#include <WebCore/FetchOptions.h>
    33 #include <WebCore/SecurityOrigin.h>
    3433#include <wtf/Seconds.h>
    3534
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r249101 r249277  
    112112    if (synchronousReply || parameters.shouldRestrictHTTPResponseAccess || parameters.options.keepAlive) {
    113113        NetworkLoadChecker::LoadType requestLoadType = isMainFrameLoad() ? NetworkLoadChecker::LoadType::MainFrame : NetworkLoadChecker::LoadType::Other;
    114         m_networkLoadChecker = makeUnique<NetworkLoadChecker>(connection.networkProcess(), FetchOptions { m_parameters.options }, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, HTTPHeaderMap { m_parameters.originalRequestHeaders }, URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, originalRequest().httpReferrer(), m_parameters.isHTTPSUpgradeEnabled, shouldCaptureExtraNetworkLoadMetrics(), requestLoadType);
     114        m_networkLoadChecker = makeUnique<NetworkLoadChecker>(connection.networkProcess(), FetchOptions { m_parameters.options }, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, HTTPHeaderMap { m_parameters.originalRequestHeaders }, URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, originalRequest().httpReferrer(), m_parameters.isHTTPSUpgradeEnabled, shouldCaptureExtraNetworkLoadMetrics(), requestLoadType);
    115115        if (m_parameters.cspResponseHeaders)
    116116            m_networkLoadChecker->setCSPResponseHeaders(ContentSecurityPolicyResponseHeaders { m_parameters.cspResponseHeaders.value() });
  • trunk/Source/WebKit/NetworkProcess/PingLoad.cpp

    r249096 r249277  
    4545    , m_completionHandler(WTFMove(completionHandler))
    4646    , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
    47     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, FetchOptions { m_parameters.options}, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
     47    , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, FetchOptions { m_parameters.options}, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
    4848{
    4949    initialize(networkProcess);
     
    5454    , m_completionHandler(WTFMove(completionHandler))
    5555    , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
    56     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, FetchOptions { m_parameters.options}, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
     56    , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, FetchOptions { m_parameters.options}, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
    5757    , m_blobFiles(connection.resolveBlobReferences(m_parameters))
    5858{
     
    149149    RELEASE_LOG_IF_ALLOWED("didReceiveChallenge");
    150150    if (challenge.protectionSpace().authenticationScheme() == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested) {
    151         m_networkLoadChecker->networkProcess().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, challenge, WTFMove(completionHandler));
     151        m_networkLoadChecker->networkProcess().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.sessionID, m_parameters.webPageID,  m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, WTFMove(completionHandler));
    152152        return;
    153153    }
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp

    r249096 r249277  
    109109}
    110110
    111 void AuthenticationManager::didReceiveAuthenticationChallenge(PAL::SessionID sessionID, PageIdentifier pageID, FrameIdentifier frameID, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
     111void AuthenticationManager::didReceiveAuthenticationChallenge(PAL::SessionID sessionID, PageIdentifier pageID, const SecurityOriginData* topOrigin, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
    112112{
    113113    ASSERT(pageID);
    114     ASSERT(frameID);
    115114
    116115    uint64_t challengeID = addChallengeToChallengeMap({ pageID, authenticationChallenge, WTFMove(completionHandler) });
     
    119118    if (shouldCoalesceChallenge(pageID, challengeID, authenticationChallenge))
    120119        return;
    121    
    122     m_process.send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(sessionID, pageID, frameID, authenticationChallenge, challengeID));
     120
     121    Optional<SecurityOriginData> topOriginData;
     122    if (topOrigin)
     123        topOriginData = *topOrigin;
     124    m_process.send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(sessionID, pageID, topOriginData, authenticationChallenge, challengeID));
    123125}
    124126
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h

    r249096 r249277  
    4444class AuthenticationChallenge;
    4545class Credential;
     46struct SecurityOriginData;
    4647}
    4748
     
    6465    static const char* supplementName();
    6566
    66     void didReceiveAuthenticationChallenge(PAL::SessionID, WebCore::PageIdentifier, WebCore::FrameIdentifier, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
     67    void didReceiveAuthenticationChallenge(PAL::SessionID, WebCore::PageIdentifier, const WebCore::SecurityOriginData* , const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    6768    void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
    6869
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r249096 r249277  
    316316}
    317317
    318 void NetworkProcessProxy::didReceiveAuthenticationChallenge(PAL::SessionID sessionID, PageIdentifier pageID, FrameIdentifier frameID, WebCore::AuthenticationChallenge&& coreChallenge, uint64_t challengeID)
     318void NetworkProcessProxy::processAuthenticationChallenge(PAL::SessionID sessionID, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
     319{
     320    auto* store = websiteDataStoreFromSessionID(sessionID);
     321    if (!store || authenticationChallenge->core().protectionSpace().authenticationScheme() != ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested) {
     322        authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling);
     323        return;
     324    }
     325    store->client().didReceiveAuthenticationChallenge(WTFMove(authenticationChallenge));
     326}
     327
     328void NetworkProcessProxy::didReceiveAuthenticationChallenge(PAL::SessionID sessionID, PageIdentifier pageID, const Optional<SecurityOriginData>& topOrigin, WebCore::AuthenticationChallenge&& coreChallenge, uint64_t challengeID)
    319329{
    320330#if HAVE(SEC_KEY_PROXY)
     
    333343
    334344    WebPageProxy* page = nullptr;
    335     if (pageID && !m_processPool.isServiceWorkerPageID(pageID))
     345    if (pageID)
    336346        page = WebProcessProxy::webPage(pageID);
    337347
    338     if (!page) {
    339         auto* store = websiteDataStoreFromSessionID(sessionID);
    340         if (!store || coreChallenge.protectionSpace().authenticationScheme() != ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested) {
    341             authenticationChallenge->listener().completeChallenge(AuthenticationChallengeDisposition::PerformDefaultHandling);
     348    if (page) {
     349        page->didReceiveAuthenticationChallengeProxy(WTFMove(authenticationChallenge));
     350        return;
     351    }
     352
     353    if (!topOrigin || !m_processPool.isServiceWorkerPageID(pageID)) {
     354        processAuthenticationChallenge(sessionID, WTFMove(authenticationChallenge));
     355        return;
     356    }
     357
     358    WebPageProxy::forMostVisibleWebPageIfAny(sessionID, *topOrigin, [this, weakThis = makeWeakPtr(this), sessionID, authenticationChallenge = WTFMove(authenticationChallenge)](auto* page) mutable {
     359        if (!weakThis)
     360            return;
     361
     362        if (page) {
     363            page->didReceiveAuthenticationChallengeProxy(WTFMove(authenticationChallenge));
    342364            return;
    343365        }
    344         store->client().didReceiveAuthenticationChallenge(WTFMove(authenticationChallenge));
    345         return;
    346     }
    347 
    348     page->didReceiveAuthenticationChallengeProxy(frameID, WTFMove(authenticationChallenge));
     366        processAuthenticationChallenge(sessionID, WTFMove(authenticationChallenge));
     367    });
    349368}
    350369
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r249096 r249277  
    214214    void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
    215215    void didCreateNetworkConnectionToWebProcess(const IPC::Attachment&);
    216     void didReceiveAuthenticationChallenge(PAL::SessionID, WebCore::PageIdentifier, WebCore::FrameIdentifier, WebCore::AuthenticationChallenge&&, uint64_t challengeID);
     216    void didReceiveAuthenticationChallenge(PAL::SessionID, WebCore::PageIdentifier, const Optional<WebCore::SecurityOriginData>&, WebCore::AuthenticationChallenge&&, uint64_t challengeID);
    217217    void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
    218218    void didDeleteWebsiteData(uint64_t callbackID);
     
    251251    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
    252252
     253    void processAuthenticationChallenge(PAL::SessionID, Ref<AuthenticationChallengeProxy>&&);
     254
    253255    WebProcessPool& m_processPool;
    254256   
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r249096 r249277  
    2424    DidCreateNetworkConnectionToWebProcess(IPC::Attachment connectionIdentifier)
    2525
    26     DidReceiveAuthenticationChallenge(PAL::SessionID sessionID, WebCore::PageIdentifier pageID, WebCore::FrameIdentifier frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
     26    DidReceiveAuthenticationChallenge(PAL::SessionID sessionID, WebCore::PageIdentifier pageID, Optional<WebCore::SecurityOriginData> topOrigin, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
    2727
    2828    DidFetchWebsiteData(uint64_t callbackID, struct WebKit::WebsiteData websiteData)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r249275 r249277  
    73357335#endif
    73367336
    7337 void WebPageProxy::didReceiveAuthenticationChallengeProxy(FrameIdentifier, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
     7337void WebPageProxy::didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
    73387338{
    73397339    m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r249275 r249277  
    12571257    WebCore::IntSize viewportSizeForCSSViewportUnits() const { return m_viewportSizeForCSSViewportUnits.valueOr(WebCore::IntSize()); }
    12581258
    1259     void didReceiveAuthenticationChallengeProxy(WebCore::FrameIdentifier, Ref<AuthenticationChallengeProxy>&&);
     1259    void didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&&);
    12601260
    12611261    SpellDocumentTag spellDocumentTag();
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r248713 r249277  
    322322            loadParameters.sourceOrigin = SecurityOrigin::createFromString(origin);
    323323    }
     324    if (document)
     325        loadParameters.topOrigin = &document->topOrigin();
    324326
    325327    if (loadParameters.options.mode != FetchOptions::Mode::Navigate) {
     
    554556    loadParameters.options = options;
    555557    loadParameters.sourceOrigin = &document->securityOrigin();
     558    loadParameters.topOrigin = &document->topOrigin();
    556559    if (!document->shouldBypassMainWorldContentSecurityPolicy()) {
    557560        if (auto* contentSecurityPolicy = document->contentSecurityPolicy())
     
    610613    loadParameters.request = request;
    611614    loadParameters.sourceOrigin = &document->securityOrigin();
     615    loadParameters.topOrigin = &document->topOrigin();
    612616    loadParameters.parentPID = presentingApplicationPID();
    613617    loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use;
Note: See TracChangeset for help on using the changeset viewer.