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

Changeset 236153 in webkit


Ignore:
Timestamp:
Sep 18, 2018, 1:55:55 PM (8 years ago)
Author:
achristensen@apple.com
Message:

Clean up AuthenticationChallengeProxy
https://bugs.webkit.org/show_bug.cgi?id=189668

Reviewed by Youenn Fablet.

At its core, it's a CompletionHandler with some information.
Make it more elegant and simple with no change in behavior and reduce the complexity of this security-sensitive object.

  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(toNSURLSessionAuthChallengeDisposition):

  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge):

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

(WKAuthenticationChallengeGetDecisionListener):
(WKAuthenticationChallengeGetProtectionSpace):
(WKAuthenticationChallengeGetProposedCredential):
(WKAuthenticationChallengeGetPreviousFailureCount):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageNavigationClient):

  • UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm:

(-[WKNSURLAuthenticationChallengeSender cancelAuthenticationChallenge:]):
(-[WKNSURLAuthenticationChallengeSender continueWithoutCredentialForAuthenticationChallenge:]):
(-[WKNSURLAuthenticationChallengeSender useCredential:forAuthenticationChallenge:]):
(-[WKNSURLAuthenticationChallengeSender performDefaultHandlingForAuthenticationChallenge:]):
(-[WKNSURLAuthenticationChallengeSender rejectProtectionSpaceAndContinueWithChallenge:]):

  • UIProcess/Authentication/AuthenticationChallengeProxy.cpp:

(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy): Deleted.
(WebKit::AuthenticationChallengeProxy::useCredential): Deleted.
(WebKit::AuthenticationChallengeProxy::cancel): Deleted.
(WebKit::AuthenticationChallengeProxy::performDefaultHandling): Deleted.
(WebKit::AuthenticationChallengeProxy::rejectProtectionSpaceAndContinue): Deleted.
(WebKit::AuthenticationChallengeProxy::proposedCredential const): Deleted.
(WebKit::AuthenticationChallengeProxy::protectionSpace const): Deleted.
(WebKit::AuthenticationChallengeProxy::setSecKeyProxyStore): Deleted.

  • UIProcess/Authentication/AuthenticationChallengeProxy.h:

(WebKit::AuthenticationChallengeProxy::create):
(WebKit::AuthenticationChallengeProxy::listener const):
(WebKit::AuthenticationChallengeProxy::previousFailureCount const): Deleted.

  • UIProcess/Authentication/AuthenticationDecisionListener.cpp:

(WebKit::AuthenticationDecisionListener::AuthenticationDecisionListener):
(WebKit::AuthenticationDecisionListener::~AuthenticationDecisionListener):
(WebKit::AuthenticationDecisionListener::useCredential):
(WebKit::AuthenticationDecisionListener::cancel):
(WebKit::AuthenticationDecisionListener::performDefaultHandling):
(WebKit::AuthenticationDecisionListener::rejectProtectionSpaceAndContinue):
(WebKit::AuthenticationDecisionListener::detachChallenge): Deleted.

  • UIProcess/Authentication/AuthenticationDecisionListener.h:

(WebKit::AuthenticationDecisionListener::create):

  • UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:

(WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc):
(WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc const): Deleted.

  • UIProcess/Cocoa/DownloadClient.mm:

(WebKit::DownloadClient::didReceiveAuthenticationChallenge):

  • UIProcess/Cocoa/NavigationState.mm:

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

  • UIProcess/Downloads/DownloadProxy.cpp:

(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):

  • UIProcess/ServiceWorkerProcessProxy.cpp:

(WebKit::ServiceWorkerProcessProxy::didReceiveAuthenticationChallenge):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::secKeyProxyStore):
(WebKit::WebPageProxy::didReceiveAuthenticationChallengeProxy):

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r236152 r236153  
     12018-09-18  Alex Christensen  <achristensen@webkit.org>
     2
     3        Clean up AuthenticationChallengeProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=189668
     5
     6        Reviewed by Youenn Fablet.
     7
     8        At its core, it's a CompletionHandler with some information.
     9        Make it more elegant and simple with no change in behavior and reduce the complexity of this security-sensitive object.
     10
     11        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     12        (toNSURLSessionAuthChallengeDisposition):
     13        * Shared/Authentication/AuthenticationManager.cpp:
     14        (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge):
     15        * Shared/Authentication/AuthenticationManager.h:
     16        * UIProcess/API/C/WKAuthenticationChallenge.cpp:
     17        (WKAuthenticationChallengeGetDecisionListener):
     18        (WKAuthenticationChallengeGetProtectionSpace):
     19        (WKAuthenticationChallengeGetProposedCredential):
     20        (WKAuthenticationChallengeGetPreviousFailureCount):
     21        * UIProcess/API/C/WKPage.cpp:
     22        (WKPageSetPageNavigationClient):
     23        * UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm:
     24        (-[WKNSURLAuthenticationChallengeSender cancelAuthenticationChallenge:]):
     25        (-[WKNSURLAuthenticationChallengeSender continueWithoutCredentialForAuthenticationChallenge:]):
     26        (-[WKNSURLAuthenticationChallengeSender useCredential:forAuthenticationChallenge:]):
     27        (-[WKNSURLAuthenticationChallengeSender performDefaultHandlingForAuthenticationChallenge:]):
     28        (-[WKNSURLAuthenticationChallengeSender rejectProtectionSpaceAndContinueWithChallenge:]):
     29        * UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
     30        (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
     31        (WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy): Deleted.
     32        (WebKit::AuthenticationChallengeProxy::useCredential): Deleted.
     33        (WebKit::AuthenticationChallengeProxy::cancel): Deleted.
     34        (WebKit::AuthenticationChallengeProxy::performDefaultHandling): Deleted.
     35        (WebKit::AuthenticationChallengeProxy::rejectProtectionSpaceAndContinue): Deleted.
     36        (WebKit::AuthenticationChallengeProxy::proposedCredential const): Deleted.
     37        (WebKit::AuthenticationChallengeProxy::protectionSpace const): Deleted.
     38        (WebKit::AuthenticationChallengeProxy::setSecKeyProxyStore): Deleted.
     39        * UIProcess/Authentication/AuthenticationChallengeProxy.h:
     40        (WebKit::AuthenticationChallengeProxy::create):
     41        (WebKit::AuthenticationChallengeProxy::listener const):
     42        (WebKit::AuthenticationChallengeProxy::previousFailureCount const): Deleted.
     43        * UIProcess/Authentication/AuthenticationDecisionListener.cpp:
     44        (WebKit::AuthenticationDecisionListener::AuthenticationDecisionListener):
     45        (WebKit::AuthenticationDecisionListener::~AuthenticationDecisionListener):
     46        (WebKit::AuthenticationDecisionListener::useCredential):
     47        (WebKit::AuthenticationDecisionListener::cancel):
     48        (WebKit::AuthenticationDecisionListener::performDefaultHandling):
     49        (WebKit::AuthenticationDecisionListener::rejectProtectionSpaceAndContinue):
     50        (WebKit::AuthenticationDecisionListener::detachChallenge): Deleted.
     51        * UIProcess/Authentication/AuthenticationDecisionListener.h:
     52        (WebKit::AuthenticationDecisionListener::create):
     53        * UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:
     54        (WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc):
     55        (WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc const): Deleted.
     56        * UIProcess/Cocoa/DownloadClient.mm:
     57        (WebKit::DownloadClient::didReceiveAuthenticationChallenge):
     58        * UIProcess/Cocoa/NavigationState.mm:
     59        (WebKit::NavigationState::NavigationClient::didReceiveAuthenticationChallenge):
     60        * UIProcess/Downloads/DownloadProxy.cpp:
     61        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
     62        * UIProcess/Network/NetworkProcessProxy.cpp:
     63        (WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):
     64        * UIProcess/ServiceWorkerProcessProxy.cpp:
     65        (WebKit::ServiceWorkerProcessProxy::didReceiveAuthenticationChallenge):
     66        * UIProcess/WebPageProxy.cpp:
     67        (WebKit::WebPageProxy::secKeyProxyStore):
     68        (WebKit::WebPageProxy::didReceiveAuthenticationChallengeProxy):
     69        * UIProcess/WebPageProxy.h:
     70
    1712018-09-18  Ben Richards  <benton_richards@apple.com>
    272
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r235585 r236153  
    7979    case WebKit::AuthenticationChallengeDisposition::Cancel:
    8080        return NSURLSessionAuthChallengeCancelAuthenticationChallenge;
    81     case WebKit::AuthenticationChallengeDisposition::RejectProtectionSpace:
     81    case WebKit::AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue:
    8282        return NSURLSessionAuthChallengeRejectProtectionSpace;
    8383    }
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp

    r235828 r236153  
    227227
    228228    if (challenge.completionHandler)
    229         challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, Credential());
     229        challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, { });
    230230    else
    231231        ASSERT_NOT_REACHED();
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h

    r234941 r236153  
    5656    PerformDefaultHandling,
    5757    Cancel,
    58     RejectProtectionSpace
     58    RejectProtectionSpaceAndContinue
    5959};
    6060using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
  • trunk/Source/WebKit/UIProcess/API/C/WKAuthenticationChallenge.cpp

    r176829 r236153  
    4343WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef challenge)
    4444{
    45     return toAPI(toImpl(challenge)->listener());
     45    return toAPI(&toImpl(challenge)->listener());
    4646}
    4747
     
    5858int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef challenge)
    5959{
    60     return toImpl(challenge)->previousFailureCount();
     60    return toImpl(challenge)->core().previousFailureCount();
    6161}
  • trunk/Source/WebKit/UIProcess/API/C/WKAuthenticationDecisionListener.cpp

    r203743 r236153  
    4040void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential)
    4141{
    42     toImpl(authenticationListener)->useCredential(toImpl(credential));
     42    if (credential)
     43        toImpl(authenticationListener)->useCredential(toImpl(credential)->credential());
     44    else
     45        toImpl(authenticationListener)->useCredential(std::nullopt);
    4346}
    4447
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r235618 r236153  
    5151#include "APIWindowFeatures.h"
    5252#include "AuthenticationChallengeProxy.h"
     53#include "AuthenticationDecisionListener.h"
    5354#include "LegacySessionStateCoding.h"
    5455#include "Logging.h"
     
    21482149        void didReceiveAuthenticationChallenge(WebPageProxy& page, AuthenticationChallengeProxy& authenticationChallenge) override
    21492150        {
    2150             if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(authenticationChallenge.protectionSpace()), m_client.base.clientInfo))
    2151                 return authenticationChallenge.rejectProtectionSpaceAndContinue();
     2151            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();
    21522153            if (!m_client.didReceiveAuthenticationChallenge)
    2153                 return authenticationChallenge.performDefaultHandling();
     2154                return authenticationChallenge.listener().performDefaultHandling();
    21542155            m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
    21552156        }
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm

    r235828 r236153  
    7171    checkChallenge(challenge);
    7272    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    73     webChallenge.listener()->cancel();
     73    webChallenge.listener().cancel();
    7474}
    7575
     
    7878    checkChallenge(challenge);
    7979    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    80     webChallenge.listener()->useCredential(nullptr);
     80    webChallenge.listener().useCredential(std::nullopt);
    8181}
    8282
     
    8585    checkChallenge(challenge);
    8686    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    87     webChallenge.listener()->useCredential(WebKit::WebCredential::create(WebCore::Credential(credential)).ptr());
     87    webChallenge.listener().useCredential(WebCore::Credential(credential));
    8888}
    8989
     
    9292    checkChallenge(challenge);
    9393    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    94     webChallenge.listener()->performDefaultHandling();
     94    webChallenge.listener().performDefaultHandling();
    9595}
    9696
     
    9999    checkChallenge(challenge);
    100100    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
    101     webChallenge.listener()->rejectProtectionSpaceAndContinue();
     101    webChallenge.listener().rejectProtectionSpaceAndContinue();
    102102}
    103103
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp

    r218487 r236153  
    2626#include "WebKitCredentialPrivate.h"
    2727#include "WebProtectionSpace.h"
     28#include <WebCore/AuthenticationChallenge.h>
     29#include <WebCore/ProtectionSpace.h>
    2830#include <glib/gi18n-lib.h>
    2931#include <wtf/glib/WTFGType.h>
     
    187189    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
    188190
    189     const WebCore::Credential& credential = request->priv->authenticationChallenge->proposedCredential()->credential();
     191    const auto& credential = request->priv->authenticationChallenge->core().proposedCredential();
    190192    if (credential.isEmpty())
    191193        return 0;
     
    209211
    210212    if (request->priv->host.isNull())
    211         request->priv->host = request->priv->authenticationChallenge->protectionSpace()->host().utf8();
     213        request->priv->host = request->priv->authenticationChallenge->core().protectionSpace().host().utf8();
    212214    return request->priv->host.data();
    213215}
     
    227229    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
    228230
    229     return request->priv->authenticationChallenge->protectionSpace()->port();
     231    return request->priv->authenticationChallenge->core().protectionSpace().port();
    230232}
    231233
     
    245247
    246248    if (request->priv->realm.isNull())
    247         request->priv->realm = request->priv->authenticationChallenge->protectionSpace()->realm().utf8();
     249        request->priv->realm = request->priv->authenticationChallenge->core().protectionSpace().realm().utf8();
    248250    return request->priv->realm.data();
    249251}
     
    263265    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN);
    264266
    265     return toWebKitAuthenticationScheme(request->priv->authenticationChallenge->protectionSpace()->authenticationScheme());
     267    return toWebKitAuthenticationScheme(request->priv->authenticationChallenge->core().protectionSpace().authenticationScheme());
    266268}
    267269
     
    280282    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), FALSE);
    281283
    282     return request->priv->authenticationChallenge->protectionSpace()->isProxy();
     284    return request->priv->authenticationChallenge->core().protectionSpace().isProxy();
    283285}
    284286
     
    297299    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
    298300
    299     return request->priv->authenticationChallenge->previousFailureCount() ? TRUE : FALSE;
     301    return request->priv->authenticationChallenge->core().previousFailureCount() ? TRUE : FALSE;
    300302}
    301303
     
    315317
    316318    if (credential)
    317         request->priv->authenticationChallenge->listener()->useCredential(WebCredential::create(webkitCredentialGetCredential(credential)).ptr());
     319        request->priv->authenticationChallenge->listener().useCredential(webkitCredentialGetCredential(credential));
    318320    else
    319         request->priv->authenticationChallenge->listener()->useCredential(nullptr);
     321        request->priv->authenticationChallenge->listener().useCredential(std::nullopt);
    320322
    321323    request->priv->handledRequest = true;
     
    335337    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
    336338
    337     request->priv->authenticationChallenge->listener()->cancel();
     339    request->priv->authenticationChallenge->listener().cancel();
    338340
    339341    g_signal_emit(request, signals[CANCELLED], 0);
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp

    r232165 r236153  
    2828
    2929#include "AuthenticationDecisionListener.h"
     30#include "AuthenticationManager.h"
    3031#include "AuthenticationManagerMessages.h"
    3132#include "ChildProcessProxy.h"
     
    4243namespace WebKit {
    4344
    44 AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, IPC::Connection* connection)
     45AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, Ref<IPC::Connection>&& connection, WeakPtr<SecKeyProxyStore>&& secKeyProxyStore)
    4546    : m_coreAuthenticationChallenge(WTFMove(authenticationChallenge))
    46     , m_challengeID(challengeID)
    47     , m_connection(connection)
     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           
     64#if HAVE(SEC_KEY_PROXY)
     65            if (secKeyProxyStore) {
     66                secKeyProxyStore->initialize(*credential);
     67                sendClientCertificateCredentialOverXpc(connection, *secKeyProxyStore, challengeID, *credential);
     68                break;
     69            }
     70#endif
     71
     72            connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, *credential), 0);
     73        }
     74    }))
    4875{
    49     ASSERT(m_challengeID);
    50     m_listener = AuthenticationDecisionListener::create(this);
    51 }
    52 
    53 AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
    54 {
    55     // If an outstanding AuthenticationChallengeProxy is being destroyed even though it hasn't been responded to yet,
    56     // we cancel it here so the process isn't waiting for an answer forever.
    57     if (m_challengeID)
    58         m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
    59 
    60     if (m_listener)
    61         m_listener->detachChallenge();
    62 }
    63 
    64 void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
    65 {
    66     if (!m_challengeID)
    67         return;
    68 
    69     uint64_t challengeID = m_challengeID;
    70     m_challengeID = 0;
    71 
    72     if (!credential) {
    73         m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
    74         return;
    75     }
    76 
    77 #if HAVE(SEC_KEY_PROXY)
    78     if (protectionSpace()->authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
    79         if (!m_secKeyProxyStore) {
    80             m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
    81             return;
    82         }
    83         m_secKeyProxyStore->initialize(credential->credential());
    84         sendClientCertificateCredentialOverXpc(challengeID, credential->credential());
    85         return;
    86     }
    87 #endif
    88     m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, credential->credential()), 0);
    89 }
    90 
    91 void AuthenticationChallengeProxy::cancel()
    92 {
    93     if (!m_challengeID)
    94         return;
    95 
    96     m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
    97 
    98     m_challengeID = 0;
    99 }
    100 
    101 void AuthenticationChallengeProxy::performDefaultHandling()
    102 {
    103     if (!m_challengeID)
    104         return;
    105 
    106     m_connection->send(Messages::AuthenticationManager::PerformDefaultHandling(m_challengeID), 0);
    107 
    108     m_challengeID = 0;
    109 }
    110 
    111 void AuthenticationChallengeProxy::rejectProtectionSpaceAndContinue()
    112 {
    113     if (!m_challengeID)
    114         return;
    115 
    116     m_connection->send(Messages::AuthenticationManager::RejectProtectionSpaceAndContinue(m_challengeID), 0);
    117 
    118     m_challengeID = 0;
    11976}
    12077
     
    12380    if (!m_webCredential)
    12481        m_webCredential = WebCredential::create(m_coreAuthenticationChallenge.proposedCredential());
    125        
     82
    12683    return m_webCredential.get();
    12784}
     
    13188    if (!m_webProtectionSpace)
    13289        m_webProtectionSpace = WebProtectionSpace::create(m_coreAuthenticationChallenge.protectionSpace());
    133        
     90
    13491    return m_webProtectionSpace.get();
    13592}
    13693
    137 #if HAVE(SEC_KEY_PROXY)
    138 void AuthenticationChallengeProxy::setSecKeyProxyStore(SecKeyProxyStore& store)
    139 {
    140     m_secKeyProxyStore = makeWeakPtr(store);
    141 }
    142 #endif
    143 
    14494} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.h

    r232165 r236153  
    4444class AuthenticationChallengeProxy : public API::ObjectImpl<API::Object::Type::AuthenticationChallenge> {
    4545public:
    46     static Ref<AuthenticationChallengeProxy> create(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, IPC::Connection* connection)
     46    static Ref<AuthenticationChallengeProxy> create(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, Ref<IPC::Connection>&& connection, WeakPtr<SecKeyProxyStore>&& secKeyProxyStore)
    4747    {
    48         return adoptRef(*new AuthenticationChallengeProxy(WTFMove(authenticationChallenge), challengeID, connection));
     48        return adoptRef(*new AuthenticationChallengeProxy(WTFMove(authenticationChallenge), challengeID, WTFMove(connection), WTFMove(secKeyProxyStore)));
    4949    }
    50    
    51     ~AuthenticationChallengeProxy();
    52    
    53     void useCredential(WebCredential*);
    54     void cancel();
    55     void performDefaultHandling();
    56     void rejectProtectionSpaceAndContinue();
    5750
    58     AuthenticationDecisionListener* listener() const { return m_listener.get(); }
    5951    WebCredential* proposedCredential() const;
    6052    WebProtectionSpace* protectionSpace() const;
    61     int previousFailureCount() const { return m_coreAuthenticationChallenge.previousFailureCount(); }
     53
     54    AuthenticationDecisionListener& listener() const { return m_listener.get(); }
    6255    const WebCore::AuthenticationChallenge& core() { return m_coreAuthenticationChallenge; }
    6356
    64 #if HAVE(SEC_KEY_PROXY)
    65     void setSecKeyProxyStore(SecKeyProxyStore&);
    66 #endif
    67 
    6857private:
    69     AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&&, uint64_t challengeID, IPC::Connection*);
     58    AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&&, uint64_t challengeID, Ref<IPC::Connection>&&, WeakPtr<SecKeyProxyStore>&&);
    7059
    7160#if HAVE(SEC_KEY_PROXY)
    72     void sendClientCertificateCredentialOverXpc(uint64_t challengeID, const WebCore::Credential&) const;
     61    static void sendClientCertificateCredentialOverXpc(IPC::Connection&, SecKeyProxyStore&, uint64_t challengeID, const WebCore::Credential&);
    7362#endif
    7463
    7564    WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
    76     uint64_t m_challengeID;
    77     RefPtr<IPC::Connection> m_connection;
    78     RefPtr<AuthenticationDecisionListener> m_listener;
    7965    mutable RefPtr<WebCredential> m_webCredential;
    8066    mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
    81 
    82 #if HAVE(SEC_KEY_PROXY)
    83     WeakPtr<SecKeyProxyStore> m_secKeyProxyStore;
    84 #endif
     67    Ref<AuthenticationDecisionListener> m_listener;
    8568};
    8669
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.cpp

    r169782 r236153  
    2828
    2929#include "AuthenticationChallengeProxy.h"
     30#include "AuthenticationManager.h"
    3031#include "AuthenticationManagerMessages.h"
    3132#include "WebCertificateInfo.h"
     
    3637namespace WebKit {
    3738
    38 AuthenticationDecisionListener::AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge)
    39     : m_challengeProxy(authenticationChallenge)
     39AuthenticationDecisionListener::AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
     40    : m_completionHandler(WTFMove(completionHandler))
    4041{
    4142}
    4243
    43 void AuthenticationDecisionListener::useCredential(WebCredential* credential)
     44AuthenticationDecisionListener::~AuthenticationDecisionListener()
    4445{
    45     if (m_challengeProxy)
    46         m_challengeProxy->useCredential(credential);
     46    if (m_completionHandler)
     47        m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
     48}
     49
     50void AuthenticationDecisionListener::useCredential(std::optional<WebCore::Credential>&& credential)
     51{
     52    if (m_completionHandler)
     53        m_completionHandler(AuthenticationChallengeDisposition::UseCredential, WTFMove(credential));
    4754}
    4855
    4956void AuthenticationDecisionListener::cancel()
    5057{
    51     if (m_challengeProxy)
    52         m_challengeProxy->cancel();
     58    if (m_completionHandler)
     59        m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
    5360}
    5461
    5562void AuthenticationDecisionListener::performDefaultHandling()
    5663{
    57     if (m_challengeProxy)
    58         m_challengeProxy->performDefaultHandling();
     64    if (m_completionHandler)
     65        m_completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, std::nullopt);
    5966}
    6067
    6168void AuthenticationDecisionListener::rejectProtectionSpaceAndContinue()
    6269{
    63     if (m_challengeProxy)
    64         m_challengeProxy->rejectProtectionSpaceAndContinue();
    65 }
    66 
    67 void AuthenticationDecisionListener::detachChallenge()
    68 {
    69     m_challengeProxy = 0;
     70    if (m_completionHandler)
     71        m_completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, std::nullopt);
    7072}
    7173   
  • trunk/Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.h

    r186059 r236153  
    2424 */
    2525
    26 #ifndef AuthenticationDecisionListener_h
    27 #define AuthenticationDecisionListener_h
     26#pragma once
    2827
    2928#include "APIObject.h"
    3029
    31 #include <wtf/RefPtr.h>
     30#include <WebCore/Credential.h>
     31#include <wtf/CompletionHandler.h>
    3232
    3333namespace WebKit {
    3434
     35enum class AuthenticationChallengeDisposition;
    3536class AuthenticationChallengeProxy;
    36 class WebCredential;
    3737
    3838class AuthenticationDecisionListener : public API::ObjectImpl<API::Object::Type::AuthenticationDecisionListener> {
    3939public:
    40     static Ref<AuthenticationDecisionListener> create(AuthenticationChallengeProxy* authenticationChallenge)
     40    static Ref<AuthenticationDecisionListener> create(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
    4141    {
    42         return adoptRef(*new AuthenticationDecisionListener(authenticationChallenge));
     42        return adoptRef(*new AuthenticationDecisionListener(WTFMove(completionHandler)));
    4343    }
     44    ~AuthenticationDecisionListener();
    4445   
    45     void useCredential(WebCredential*);
     46    void useCredential(std::optional<WebCore::Credential>&&);
    4647    void cancel();
    4748    void performDefaultHandling();
    4849    void rejectProtectionSpaceAndContinue();
    4950
    50     void detachChallenge();
     51private:
     52    explicit AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&&);
    5153
    52 private:
    53     explicit AuthenticationDecisionListener(AuthenticationChallengeProxy*);
    54 
    55     AuthenticationChallengeProxy* m_challengeProxy;
     54    CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)> m_completionHandler;
    5655};
    5756
    5857} // namespace WebKit
    59 
    60 #endif // WebAuthenticationDecisionListener_h
  • trunk/Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm

    r232165 r236153  
    3737namespace WebKit {
    3838
    39 void AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc(uint64_t challengeID, const WebCore::Credential& credential) const
     39void AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc(IPC::Connection& connection, SecKeyProxyStore& secKeyProxyStore, uint64_t challengeID, const WebCore::Credential& credential)
    4040{
    41     ASSERT(m_secKeyProxyStore);
    42     ASSERT(m_secKeyProxyStore->isInitialized());
     41    ASSERT(secKeyProxyStore.isInitialized());
    4342
    4443    auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
    4544    xpc_dictionary_set_string(message.get(), clientCertificateAuthenticationXPCMessageNameKey, clientCertificateAuthenticationXPCMessageNameValue);
    4645    xpc_dictionary_set_uint64(message.get(), clientCertificateAuthenticationXPCChallengeIDKey, challengeID);
    47     xpc_dictionary_set_value(message.get(), clientCertificateAuthenticationXPCSecKeyProxyEndpointKey, m_secKeyProxyStore->get().endpoint._endpoint);
     46    xpc_dictionary_set_value(message.get(), clientCertificateAuthenticationXPCSecKeyProxyEndpointKey, secKeyProxyStore.get().endpoint._endpoint);
    4847    auto certificateDataArray = adoptOSObject(xpc_array_create(nullptr, 0));
    4948    for (id certificate in credential.nsCredential().certificates) {
     
    5453    xpc_dictionary_set_uint64(message.get(), clientCertificateAuthenticationXPCPersistenceKey, static_cast<uint64_t>(credential.nsCredential().persistence));
    5554
    56     xpc_connection_send_message(m_connection->xpcConnection(), message.get());
     55    xpc_connection_send_message(connection.xpcConnection(), message.get());
    5756}
    5857
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r235935 r236153  
    123123    // FIXME: System Preview needs code here.
    124124    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
    125         authenticationChallenge.listener()->performDefaultHandling();
     125        authenticationChallenge.listener().performDefaultHandling();
    126126        return;
    127127    }
     
    132132        checker->didCallCompletionHandler();
    133133        switch (disposition) {
    134         case NSURLSessionAuthChallengeUseCredential: {
    135             RefPtr<WebCredential> webCredential;
     134        case NSURLSessionAuthChallengeUseCredential:
    136135            if (credential)
    137                 webCredential = WebCredential::create(WebCore::Credential(credential));
    138            
    139             authenticationChallenge->listener()->useCredential(webCredential.get());
     136                authenticationChallenge->listener().useCredential(WebCore::Credential(credential));
     137            else
     138                authenticationChallenge->listener().useCredential(std::nullopt);
    140139            break;
    141         }
    142            
    143140        case NSURLSessionAuthChallengePerformDefaultHandling:
    144             authenticationChallenge->listener()->performDefaultHandling();
     141            authenticationChallenge->listener().performDefaultHandling();
    145142            break;
    146143           
    147144        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
    148             authenticationChallenge->listener()->cancel();
     145            authenticationChallenge->listener().cancel();
    149146            break;
    150147           
    151148        case NSURLSessionAuthChallengeRejectProtectionSpace:
    152             authenticationChallenge->listener()->rejectProtectionSpaceAndContinue();
     149            authenticationChallenge->listener().rejectProtectionSpaceAndContinue();
    153150            break;
    154151           
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r235935 r236153  
    853853{
    854854    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
    855         return authenticationChallenge.performDefaultHandling();
    856 
    857     auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
    858     if (!navigationDelegate)
    859         return authenticationChallenge.performDefaultHandling();
     855        return authenticationChallenge.listener().performDefaultHandling();
     856
     857    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
     858    if (!navigationDelegate)
     859        return authenticationChallenge.listener().performDefaultHandling();
    860860
    861861    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
     
    866866
    867867        switch (disposition) {
    868         case NSURLSessionAuthChallengeUseCredential: {
    869             RefPtr<WebCredential> webCredential;
     868        case NSURLSessionAuthChallengeUseCredential:
    870869            if (credential)
    871                 webCredential = WebCredential::create(WebCore::Credential(credential));
    872 
    873             challenge->useCredential(webCredential.get());
     870                challenge->listener().useCredential(Credential(credential));
     871            else
     872                challenge->listener().useCredential(std::nullopt);
    874873            break;
    875         }
    876 
    877874        case NSURLSessionAuthChallengePerformDefaultHandling:
    878             challenge->performDefaultHandling();
     875            challenge->listener().performDefaultHandling();
    879876            break;
    880877
    881878        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
    882             challenge->cancel();
     879            challenge->listener().cancel();
    883880            break;
    884881
    885882        case NSURLSessionAuthChallengeRejectProtectionSpace:
    886             challenge->rejectProtectionSpaceAndContinue();
     883            challenge->listener().rejectProtectionSpaceAndContinue();
    887884            break;
    888885
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp

    r235265 r236153  
    121121        return;
    122122
    123     auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, m_processPool->networkingProcessConnection());
     123    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, makeRef(*m_processPool->networkingProcessConnection()), nullptr);
    124124
    125125    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r236035 r236153  
    295295#if ENABLE(SERVICE_WORKER)
    296296    if (auto* serviceWorkerProcessProxy = m_processPool.serviceWorkerProcessProxyFromPageID(pageID)) {
    297         auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, connection());
     297        auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, makeRef(*connection()), nullptr);
    298298        serviceWorkerProcessProxy->didReceiveAuthenticationChallenge(pageID, frameID, WTFMove(authenticationChallenge));
    299299        return;
     
    304304    MESSAGE_CHECK(page);
    305305
    306     auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, connection());
     306    auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, makeRef(*connection()), page->secKeyProxyStore(coreChallenge));
    307307    page->didReceiveAuthenticationChallengeProxy(frameID, WTFMove(authenticationChallenge));
    308308}
  • trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp

    r235632 r236153  
    3030
    3131#include "AuthenticationChallengeProxy.h"
     32#include "AuthenticationDecisionListener.h"
    3233#include "WebCredential.h"
    3334#include "WebPageGroup.h"
     
    9899    if (protectionSpace.authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested && processPool().allowsAnySSLCertificateForServiceWorker()) {
    99100        auto credential = WebCore::Credential("accept server trust"_s, emptyString(), WebCore::CredentialPersistenceNone);
    100         challenge->useCredential(WebCredential::create(credential).ptr());
     101        challenge->listener().useCredential(credential);
    101102        return;
    102103    }
    103104    notImplemented();
    104     challenge->performDefaultHandling();
     105    challenge->listener().performDefaultHandling();
    105106}
    106107
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r236146 r236153  
    63356335#endif
    63366336
     6337WeakPtr<SecKeyProxyStore> WebPageProxy::secKeyProxyStore(const WebCore::AuthenticationChallenge& challenge)
     6338{
     6339#if HAVE(SEC_KEY_PROXY)
     6340    if (challenge.protectionSpace().authenticationScheme() == ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
     6341        auto secKeyProxyStore = SecKeyProxyStore::create();
     6342        auto weakPointer = makeWeakPtr(secKeyProxyStore.get());
     6343        m_websiteDataStore->addSecKeyProxyStore(WTFMove(secKeyProxyStore));
     6344        return weakPointer;
     6345    }
     6346#endif
     6347    return nullptr;
     6348}
     6349   
    63376350void WebPageProxy::didReceiveAuthenticationChallengeProxy(uint64_t, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
    63386351{
    6339 #if HAVE(SEC_KEY_PROXY)
    6340     ASSERT(authenticationChallenge->protectionSpace());
    6341     if (authenticationChallenge->protectionSpace()->authenticationScheme() == ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
    6342         auto secKeyProxyStore = SecKeyProxyStore::create();
    6343         authenticationChallenge->setSecKeyProxyStore(secKeyProxyStore);
    6344         m_websiteDataStore->addSecKeyProxyStore(WTFMove(secKeyProxyStore));
    6345     }
    6346 #endif
    6347 
    63486352    if (m_navigationClient)
    63496353        m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());
    63506354    else
    6351         authenticationChallenge->performDefaultHandling();
     6355        authenticationChallenge->listener().performDefaultHandling();
    63526356}
    63536357
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r236146 r236153  
    226226class RemoteLayerTreeTransaction;
    227227class RemoteScrollingCoordinatorProxy;
     228class SecKeyProxyStore;
    228229class UserData;
    229230class ViewSnapshot;
     
    437438    void initializeWebPage();
    438439
     440    WeakPtr<SecKeyProxyStore> secKeyProxyStore(const WebCore::AuthenticationChallenge&);
     441       
    439442    void close();
    440443    bool tryClose();
Note: See TracChangeset for help on using the changeset viewer.