| Differences between
and this patch
- Source/WebKit/ChangeLog +70 lines
Lines 1-3 Source/WebKit/ChangeLog_sec1
1
2018-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
1
+2018-08-17  Ben Richards  <benton_richards@apple.com>
71
+2018-08-17  Ben Richards  <benton_richards@apple.com>
2
72
3
        Add script to generate WebContent service resource files and change XPC service main SPI to have it's own header
73
        Add script to generate WebContent service resource files and change XPC service main SPI to have it's own header
- Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm -1 / +1 lines
Lines 78-84 static NSURLSessionAuthChallengeDisposit Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm_sec1
78
        return NSURLSessionAuthChallengePerformDefaultHandling;
78
        return NSURLSessionAuthChallengePerformDefaultHandling;
79
    case WebKit::AuthenticationChallengeDisposition::Cancel:
79
    case WebKit::AuthenticationChallengeDisposition::Cancel:
80
        return NSURLSessionAuthChallengeCancelAuthenticationChallenge;
80
        return NSURLSessionAuthChallengeCancelAuthenticationChallenge;
81
    case WebKit::AuthenticationChallengeDisposition::RejectProtectionSpace:
81
    case WebKit::AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue:
82
        return NSURLSessionAuthChallengeRejectProtectionSpace;
82
        return NSURLSessionAuthChallengeRejectProtectionSpace;
83
    }
83
    }
84
}
84
}
- Source/WebKit/Shared/Authentication/AuthenticationManager.cpp -1 / +1 lines
Lines 226-232 void AuthenticationManager::rejectProtec Source/WebKit/Shared/Authentication/AuthenticationManager.cpp_sec1
226
    ASSERT(!challenge.challenge.isNull());
226
    ASSERT(!challenge.challenge.isNull());
227
227
228
    if (challenge.completionHandler)
228
    if (challenge.completionHandler)
229
        challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, Credential());
229
        challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, { });
230
    else
230
    else
231
        ASSERT_NOT_REACHED();
231
        ASSERT_NOT_REACHED();
232
}
232
}
- Source/WebKit/Shared/Authentication/AuthenticationManager.h -1 / +1 lines
Lines 55-61 enum class AuthenticationChallengeDispos Source/WebKit/Shared/Authentication/AuthenticationManager.h_sec1
55
    UseCredential,
55
    UseCredential,
56
    PerformDefaultHandling,
56
    PerformDefaultHandling,
57
    Cancel,
57
    Cancel,
58
    RejectProtectionSpace
58
    RejectProtectionSpaceAndContinue
59
};
59
};
60
using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
60
using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
61
61
- Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp -2 / +3 lines
Lines 29-34 Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp_sec1
29
#if ENABLE(SERVICE_WORKER)
29
#if ENABLE(SERVICE_WORKER)
30
30
31
#include "AuthenticationChallengeProxy.h"
31
#include "AuthenticationChallengeProxy.h"
32
#include "AuthenticationDecisionListener.h"
32
#include "WebCredential.h"
33
#include "WebCredential.h"
33
#include "WebPageGroup.h"
34
#include "WebPageGroup.h"
34
#include "WebPreferencesStore.h"
35
#include "WebPreferencesStore.h"
Lines 97-107 void ServiceWorkerProcessProxy::didRecei Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp_sec2
97
    auto& protectionSpace = challenge->core().protectionSpace();
98
    auto& protectionSpace = challenge->core().protectionSpace();
98
    if (protectionSpace.authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested && processPool().allowsAnySSLCertificateForServiceWorker()) {
99
    if (protectionSpace.authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested && processPool().allowsAnySSLCertificateForServiceWorker()) {
99
        auto credential = WebCore::Credential("accept server trust"_s, emptyString(), WebCore::CredentialPersistenceNone);
100
        auto credential = WebCore::Credential("accept server trust"_s, emptyString(), WebCore::CredentialPersistenceNone);
100
        challenge->useCredential(WebCredential::create(credential).ptr());
101
        challenge->listener().useCredential(credential);
101
        return;
102
        return;
102
    }
103
    }
103
    notImplemented();
104
    notImplemented();
104
    challenge->performDefaultHandling();
105
    challenge->listener().performDefaultHandling();
105
}
106
}
106
107
107
void ServiceWorkerProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
108
void ServiceWorkerProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
- Source/WebKit/UIProcess/WebPageProxy.cpp -6 / +10 lines
Lines 6334-6354 void WebPageProxy::gamepadActivity(const Source/WebKit/UIProcess/WebPageProxy.cpp_sec1
6334
6334
6335
#endif
6335
#endif
6336
6336
6337
void WebPageProxy::didReceiveAuthenticationChallengeProxy(uint64_t, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
6337
WeakPtr<SecKeyProxyStore> WebPageProxy::secKeyProxyStore(const WebCore::AuthenticationChallenge& challenge)
6338
{
6338
{
6339
#if HAVE(SEC_KEY_PROXY)
6339
#if HAVE(SEC_KEY_PROXY)
6340
    ASSERT(authenticationChallenge->protectionSpace());
6340
    if (challenge.protectionSpace().authenticationScheme() == ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
6341
    if (authenticationChallenge->protectionSpace()->authenticationScheme() == ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
6342
        auto secKeyProxyStore = SecKeyProxyStore::create();
6341
        auto secKeyProxyStore = SecKeyProxyStore::create();
6343
        authenticationChallenge->setSecKeyProxyStore(secKeyProxyStore);
6342
        auto weakPointer = makeWeakPtr(secKeyProxyStore.get());
6344
        m_websiteDataStore->addSecKeyProxyStore(WTFMove(secKeyProxyStore));
6343
        m_websiteDataStore->addSecKeyProxyStore(WTFMove(secKeyProxyStore));
6344
        return weakPointer;
6345
    }
6345
    }
6346
#endif
6346
#endif
6347
6347
    return nullptr;
6348
}
6349
    
6350
void WebPageProxy::didReceiveAuthenticationChallengeProxy(uint64_t, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
6351
{
6348
    if (m_navigationClient)
6352
    if (m_navigationClient)
6349
        m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());
6353
        m_navigationClient->didReceiveAuthenticationChallenge(*this, authenticationChallenge.get());
6350
    else
6354
    else
6351
        authenticationChallenge->performDefaultHandling();
6355
        authenticationChallenge->listener().performDefaultHandling();
6352
}
6356
}
6353
6357
6354
void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply&& reply)
6358
void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply&& reply)
- Source/WebKit/UIProcess/WebPageProxy.h +3 lines
Lines 225-230 class PageClient; Source/WebKit/UIProcess/WebPageProxy.h_sec1
225
class RemoteLayerTreeScrollingPerformanceData;
225
class RemoteLayerTreeScrollingPerformanceData;
226
class RemoteLayerTreeTransaction;
226
class RemoteLayerTreeTransaction;
227
class RemoteScrollingCoordinatorProxy;
227
class RemoteScrollingCoordinatorProxy;
228
class SecKeyProxyStore;
228
class UserData;
229
class UserData;
229
class ViewSnapshot;
230
class ViewSnapshot;
230
class VisitedLinkStore;
231
class VisitedLinkStore;
Lines 436-441 public: Source/WebKit/UIProcess/WebPageProxy.h_sec2
436
437
437
    void initializeWebPage();
438
    void initializeWebPage();
438
439
440
    WeakPtr<SecKeyProxyStore> secKeyProxyStore(const WebCore::AuthenticationChallenge&);
441
        
439
    void close();
442
    void close();
440
    bool tryClose();
443
    bool tryClose();
441
    bool isClosed() const { return m_isClosed; }
444
    bool isClosed() const { return m_isClosed; }
- Source/WebKit/UIProcess/API/C/WKAuthenticationChallenge.cpp -2 / +2 lines
Lines 42-48 WKTypeID WKAuthenticationChallengeGetTyp Source/WebKit/UIProcess/API/C/WKAuthenticationChallenge.cpp_sec1
42
42
43
WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef challenge)
43
WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef challenge)
44
{
44
{
45
    return toAPI(toImpl(challenge)->listener());
45
    return toAPI(&toImpl(challenge)->listener());
46
}
46
}
47
47
48
WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef challenge)
48
WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef challenge)
Lines 57-61 WKCredentialRef WKAuthenticationChalleng Source/WebKit/UIProcess/API/C/WKAuthenticationChallenge.cpp_sec2
57
57
58
int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef challenge)
58
int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef challenge)
59
{
59
{
60
    return toImpl(challenge)->previousFailureCount();
60
    return toImpl(challenge)->core().previousFailureCount();
61
}
61
}
- Source/WebKit/UIProcess/API/C/WKAuthenticationDecisionListener.cpp -1 / +4 lines
Lines 39-45 WKTypeID WKAuthenticationDecisionListene Source/WebKit/UIProcess/API/C/WKAuthenticationDecisionListener.cpp_sec1
39
39
40
void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential)
40
void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential)
41
{
41
{
42
    toImpl(authenticationListener)->useCredential(toImpl(credential));
42
    if (credential)
43
        toImpl(authenticationListener)->useCredential(toImpl(credential)->credential());
44
    else
45
        toImpl(authenticationListener)->useCredential(std::nullopt);
43
}
46
}
44
47
45
void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener)
48
void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener)
- Source/WebKit/UIProcess/API/C/WKPage.cpp -3 / +4 lines
Lines 50-55 Source/WebKit/UIProcess/API/C/WKPage.cpp_sec1
50
#include "APIWebsitePolicies.h"
50
#include "APIWebsitePolicies.h"
51
#include "APIWindowFeatures.h"
51
#include "APIWindowFeatures.h"
52
#include "AuthenticationChallengeProxy.h"
52
#include "AuthenticationChallengeProxy.h"
53
#include "AuthenticationDecisionListener.h"
53
#include "LegacySessionStateCoding.h"
54
#include "LegacySessionStateCoding.h"
54
#include "Logging.h"
55
#include "Logging.h"
55
#include "NativeWebKeyboardEvent.h"
56
#include "NativeWebKeyboardEvent.h"
Lines 2147-2156 void WKPageSetPageNavigationClient(WKPag Source/WebKit/UIProcess/API/C/WKPage.cpp_sec2
2147
        
2148
        
2148
        void didReceiveAuthenticationChallenge(WebPageProxy& page, AuthenticationChallengeProxy& authenticationChallenge) override
2149
        void didReceiveAuthenticationChallenge(WebPageProxy& page, AuthenticationChallengeProxy& authenticationChallenge) override
2149
        {
2150
        {
2150
            if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(authenticationChallenge.protectionSpace()), m_client.base.clientInfo))
2151
            if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(WebProtectionSpace::create(authenticationChallenge.core().protectionSpace()).ptr()), m_client.base.clientInfo))
2151
                return authenticationChallenge.rejectProtectionSpaceAndContinue();
2152
                return authenticationChallenge.listener().rejectProtectionSpaceAndContinue();
2152
            if (!m_client.didReceiveAuthenticationChallenge)
2153
            if (!m_client.didReceiveAuthenticationChallenge)
2153
                return authenticationChallenge.performDefaultHandling();
2154
                return authenticationChallenge.listener().performDefaultHandling();
2154
            m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
2155
            m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
2155
        }
2156
        }
2156
2157
- Source/WebKit/UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm -5 / +5 lines
Lines 70-104 - (void)cancelAuthenticationChallenge:(N Source/WebKit/UIProcess/API/Cocoa/WKNSURLAuthenticationChallenge.mm_sec1
70
{
70
{
71
    checkChallenge(challenge);
71
    checkChallenge(challenge);
72
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
72
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
73
    webChallenge.listener()->cancel();
73
    webChallenge.listener().cancel();
74
}
74
}
75
75
76
- (void)continueWithoutCredentialForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
76
- (void)continueWithoutCredentialForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
77
{
77
{
78
    checkChallenge(challenge);
78
    checkChallenge(challenge);
79
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
79
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
80
    webChallenge.listener()->useCredential(nullptr);
80
    webChallenge.listener().useCredential(std::nullopt);
81
}
81
}
82
82
83
- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
83
- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
84
{
84
{
85
    checkChallenge(challenge);
85
    checkChallenge(challenge);
86
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
86
    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));
88
}
88
}
89
89
90
- (void)performDefaultHandlingForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
90
- (void)performDefaultHandlingForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
91
{
91
{
92
    checkChallenge(challenge);
92
    checkChallenge(challenge);
93
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
93
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
94
    webChallenge.listener()->performDefaultHandling();
94
    webChallenge.listener().performDefaultHandling();
95
}
95
}
96
96
97
- (void)rejectProtectionSpaceAndContinueWithChallenge:(NSURLAuthenticationChallenge *)challenge
97
- (void)rejectProtectionSpaceAndContinueWithChallenge:(NSURLAuthenticationChallenge *)challenge
98
{
98
{
99
    checkChallenge(challenge);
99
    checkChallenge(challenge);
100
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
100
    WebKit::AuthenticationChallengeProxy& webChallenge = ((WKNSURLAuthenticationChallenge *)challenge)._web_authenticationChallengeProxy;
101
    webChallenge.listener()->rejectProtectionSpaceAndContinue();
101
    webChallenge.listener().rejectProtectionSpaceAndContinue();
102
}
102
}
103
103
104
@end
104
@end
- Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp -10 / +12 lines
Lines 25-30 Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec1
25
#include "WebKitAuthenticationRequestPrivate.h"
25
#include "WebKitAuthenticationRequestPrivate.h"
26
#include "WebKitCredentialPrivate.h"
26
#include "WebKitCredentialPrivate.h"
27
#include "WebProtectionSpace.h"
27
#include "WebProtectionSpace.h"
28
#include <WebCore/AuthenticationChallenge.h>
29
#include <WebCore/ProtectionSpace.h>
28
#include <glib/gi18n-lib.h>
30
#include <glib/gi18n-lib.h>
29
#include <wtf/glib/WTFGType.h>
31
#include <wtf/glib/WTFGType.h>
30
#include <wtf/text/CString.h>
32
#include <wtf/text/CString.h>
Lines 186-192 WebKitCredential* webkit_authentication_ Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec2
186
{
188
{
187
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
189
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
188
190
189
    const WebCore::Credential& credential = request->priv->authenticationChallenge->proposedCredential()->credential();
191
    const auto& credential = request->priv->authenticationChallenge->core().proposedCredential();
190
    if (credential.isEmpty())
192
    if (credential.isEmpty())
191
        return 0;
193
        return 0;
192
194
Lines 208-214 const gchar* webkit_authentication_reque Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec3
208
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
210
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
209
211
210
    if (request->priv->host.isNull())
212
    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();
212
    return request->priv->host.data();
214
    return request->priv->host.data();
213
}
215
}
214
216
Lines 226-232 guint webkit_authentication_request_get_ Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec4
226
{
228
{
227
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
229
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
228
230
229
    return request->priv->authenticationChallenge->protectionSpace()->port();
231
    return request->priv->authenticationChallenge->core().protectionSpace().port();
230
}
232
}
231
233
232
/**
234
/**
Lines 244-250 const gchar* webkit_authentication_reque Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec5
244
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
246
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
245
247
246
    if (request->priv->realm.isNull())
248
    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();
248
    return request->priv->realm.data();
250
    return request->priv->realm.data();
249
}
251
}
250
252
Lines 262-268 WebKitAuthenticationScheme webkit_authen Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec6
262
{
264
{
263
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN);
265
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), WEBKIT_AUTHENTICATION_SCHEME_UNKNOWN);
264
266
265
    return toWebKitAuthenticationScheme(request->priv->authenticationChallenge->protectionSpace()->authenticationScheme());
267
    return toWebKitAuthenticationScheme(request->priv->authenticationChallenge->core().protectionSpace().authenticationScheme());
266
}
268
}
267
269
268
/**
270
/**
Lines 279-285 gboolean webkit_authentication_request_i Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec7
279
{
281
{
280
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), FALSE);
282
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), FALSE);
281
283
282
    return request->priv->authenticationChallenge->protectionSpace()->isProxy();
284
    return request->priv->authenticationChallenge->core().protectionSpace().isProxy();
283
}
285
}
284
286
285
/**
287
/**
Lines 296-302 gboolean webkit_authentication_request_i Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec8
296
{
298
{
297
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
299
    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), 0);
298
300
299
    return request->priv->authenticationChallenge->previousFailureCount() ? TRUE : FALSE;
301
    return request->priv->authenticationChallenge->core().previousFailureCount() ? TRUE : FALSE;
300
}
302
}
301
303
302
/**
304
/**
Lines 314-322 void webkit_authentication_request_authe Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec9
314
    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
316
    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
315
317
316
    if (credential)
318
    if (credential)
317
        request->priv->authenticationChallenge->listener()->useCredential(WebCredential::create(webkitCredentialGetCredential(credential)).ptr());
319
        request->priv->authenticationChallenge->listener().useCredential(WebCredential::create(webkitCredentialGetCredential(credential)).ptr());
318
    else
320
    else
319
        request->priv->authenticationChallenge->listener()->useCredential(nullptr);
321
        request->priv->authenticationChallenge->listener().useCredential(nullptr);
320
322
321
    request->priv->handledRequest = true;
323
    request->priv->handledRequest = true;
322
}
324
}
Lines 334-340 void webkit_authentication_request_cance Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp_sec10
334
{
336
{
335
    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
337
    g_return_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request));
336
338
337
    request->priv->authenticationChallenge->listener()->cancel();
339
    request->priv->authenticationChallenge->listener().cancel();
338
340
339
    g_signal_emit(request, signals[CANCELLED], 0);
341
    g_signal_emit(request, signals[CANCELLED], 0);
340
}
342
}
- Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp -79 / +29 lines
Lines 27-32 Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp_sec1
27
#include "AuthenticationChallengeProxy.h"
27
#include "AuthenticationChallengeProxy.h"
28
28
29
#include "AuthenticationDecisionListener.h"
29
#include "AuthenticationDecisionListener.h"
30
#include "AuthenticationManager.h"
30
#include "AuthenticationManagerMessages.h"
31
#include "AuthenticationManagerMessages.h"
31
#include "ChildProcessProxy.h"
32
#include "ChildProcessProxy.h"
32
#include "WebCertificateInfo.h"
33
#include "WebCertificateInfo.h"
Lines 41-128 Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp_sec2
41
42
42
namespace WebKit {
43
namespace WebKit {
43
44
44
AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, IPC::Connection* connection)
45
AuthenticationChallengeProxy::AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID, Ref<IPC::Connection>&& connection, WeakPtr<SecKeyProxyStore>&& secKeyProxyStore)
45
    : m_coreAuthenticationChallenge(WTFMove(authenticationChallenge))
46
    : m_coreAuthenticationChallenge(WTFMove(authenticationChallenge))
46
    , m_challengeID(challengeID)
47
    , m_listener(AuthenticationDecisionListener::create([challengeID, connection = WTFMove(connection), secKeyProxyStore = WTFMove(secKeyProxyStore)](AuthenticationChallengeDisposition disposition, std::optional<WebCore::Credential>&& credential) {
47
    , m_connection(connection)
48
        switch (disposition) {
48
{
49
        case AuthenticationChallengeDisposition::Cancel:
49
    ASSERT(m_challengeID);
50
            connection->send(Messages::AuthenticationManager::CancelChallenge(challengeID), 0);
50
    m_listener = AuthenticationDecisionListener::create(this);
51
            break;
51
}
52
        case AuthenticationChallengeDisposition::PerformDefaultHandling:
52
53
            connection->send(Messages::AuthenticationManager::PerformDefaultHandling(challengeID), 0);
53
AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
54
            break;
54
{
55
        case AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue:
55
    // If an outstanding AuthenticationChallengeProxy is being destroyed even though it hasn't been responded to yet,
56
            connection->send(Messages::AuthenticationManager::RejectProtectionSpaceAndContinue(challengeID), 0);
56
    // we cancel it here so the process isn't waiting for an answer forever.
57
            break;
57
    if (m_challengeID)
58
        case AuthenticationChallengeDisposition::UseCredential:
58
        m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
59
            if (!credential) {
59
60
                connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
60
    if (m_listener)
61
                break;
61
        m_listener->detachChallenge();
62
            }
62
}
63
            
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)
64
#if HAVE(SEC_KEY_PROXY)
78
    if (protectionSpace()->authenticationScheme() == WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested) {
65
            if (secKeyProxyStore) {
79
        if (!m_secKeyProxyStore) {
66
                secKeyProxyStore->initialize(*credential);
80
            m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(challengeID), 0);
67
                sendClientCertificateCredentialOverXpc(connection, *secKeyProxyStore, challengeID, *credential);
81
            return;
68
                break;
82
        }
69
            }
83
        m_secKeyProxyStore->initialize(credential->credential());
84
        sendClientCertificateCredentialOverXpc(challengeID, credential->credential());
85
        return;
86
    }
87
#endif
70
#endif
88
    m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, credential->credential()), 0);
89
}
90
71
91
void AuthenticationChallengeProxy::cancel()
72
            connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(challengeID, *credential), 0);
92
{
73
        }
93
    if (!m_challengeID)
74
    }))
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
{
75
{
113
    if (!m_challengeID)
114
        return;
115
116
    m_connection->send(Messages::AuthenticationManager::RejectProtectionSpaceAndContinue(m_challengeID), 0);
117
118
    m_challengeID = 0;
119
}
76
}
120
77
121
WebCredential* AuthenticationChallengeProxy::proposedCredential() const
78
WebCredential* AuthenticationChallengeProxy::proposedCredential() const
122
{
79
{
123
    if (!m_webCredential)
80
    if (!m_webCredential)
124
        m_webCredential = WebCredential::create(m_coreAuthenticationChallenge.proposedCredential());
81
        m_webCredential = WebCredential::create(m_coreAuthenticationChallenge.proposedCredential());
125
        
82
126
    return m_webCredential.get();
83
    return m_webCredential.get();
127
}
84
}
128
85
Lines 130-144 WebProtectionSpace* AuthenticationChalle Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.cpp_sec3
130
{
87
{
131
    if (!m_webProtectionSpace)
88
    if (!m_webProtectionSpace)
132
        m_webProtectionSpace = WebProtectionSpace::create(m_coreAuthenticationChallenge.protectionSpace());
89
        m_webProtectionSpace = WebProtectionSpace::create(m_coreAuthenticationChallenge.protectionSpace());
133
        
134
    return m_webProtectionSpace.get();
135
}
136
90
137
#if HAVE(SEC_KEY_PROXY)
91
    return m_webProtectionSpace.get();
138
void AuthenticationChallengeProxy::setSecKeyProxyStore(SecKeyProxyStore& store)
139
{
140
    m_secKeyProxyStore = makeWeakPtr(store);
141
}
92
}
142
#endif
143
93
144
} // namespace WebKit
94
} // namespace WebKit
- Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.h -24 / +7 lines
Lines 43-87 class WebProtectionSpace; Source/WebKit/UIProcess/Authentication/AuthenticationChallengeProxy.h_sec1
43
43
44
class AuthenticationChallengeProxy : public API::ObjectImpl<API::Object::Type::AuthenticationChallenge> {
44
class AuthenticationChallengeProxy : public API::ObjectImpl<API::Object::Type::AuthenticationChallenge> {
45
public:
45
public:
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)
47
    {
47
    {
48
        return adoptRef(*new AuthenticationChallengeProxy(WTFMove(authenticationChallenge), challengeID, connection));
48
        return adoptRef(*new AuthenticationChallengeProxy(WTFMove(authenticationChallenge), challengeID, WTFMove(connection), WTFMove(secKeyProxyStore)));
49
    }
49
    }
50
    
51
    ~AuthenticationChallengeProxy();
52
    
53
    void useCredential(WebCredential*);
54
    void cancel();
55
    void performDefaultHandling();
56
    void rejectProtectionSpaceAndContinue();
57
50
58
    AuthenticationDecisionListener* listener() const { return m_listener.get(); }
59
    WebCredential* proposedCredential() const;
51
    WebCredential* proposedCredential() const;
60
    WebProtectionSpace* protectionSpace() const;
52
    WebProtectionSpace* protectionSpace() const;
61
    int previousFailureCount() const { return m_coreAuthenticationChallenge.previousFailureCount(); }
62
    const WebCore::AuthenticationChallenge& core() { return m_coreAuthenticationChallenge; }
63
53
64
#if HAVE(SEC_KEY_PROXY)
54
    AuthenticationDecisionListener& listener() const { return m_listener.get(); }
65
    void setSecKeyProxyStore(SecKeyProxyStore&);
55
    const WebCore::AuthenticationChallenge& core() { return m_coreAuthenticationChallenge; }
66
#endif
67
56
68
private:
57
private:
69
    AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&&, uint64_t challengeID, IPC::Connection*);
58
    AuthenticationChallengeProxy(WebCore::AuthenticationChallenge&&, uint64_t challengeID, Ref<IPC::Connection>&&, WeakPtr<SecKeyProxyStore>&&);
70
59
71
#if HAVE(SEC_KEY_PROXY)
60
#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&);
73
#endif
62
#endif
74
63
75
    WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
64
    WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
76
    uint64_t m_challengeID;
77
    RefPtr<IPC::Connection> m_connection;
78
    RefPtr<AuthenticationDecisionListener> m_listener;
79
    mutable RefPtr<WebCredential> m_webCredential;
65
    mutable RefPtr<WebCredential> m_webCredential;
80
    mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
66
    mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
81
67
    Ref<AuthenticationDecisionListener> m_listener;
82
#if HAVE(SEC_KEY_PROXY)
83
    WeakPtr<SecKeyProxyStore> m_secKeyProxyStore;
84
#endif
85
};
68
};
86
69
87
} // namespace WebKit
70
} // namespace WebKit
- Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.cpp -16 / +18 lines
Lines 27-32 Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.cpp_sec1
27
#include "AuthenticationDecisionListener.h"
27
#include "AuthenticationDecisionListener.h"
28
28
29
#include "AuthenticationChallengeProxy.h"
29
#include "AuthenticationChallengeProxy.h"
30
#include "AuthenticationManager.h"
30
#include "AuthenticationManagerMessages.h"
31
#include "AuthenticationManagerMessages.h"
31
#include "WebCertificateInfo.h"
32
#include "WebCertificateInfo.h"
32
#include "WebCredential.h"
33
#include "WebCredential.h"
Lines 35-72 Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.cpp_sec2
35
36
36
namespace WebKit {
37
namespace WebKit {
37
38
38
AuthenticationDecisionListener::AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge)
39
AuthenticationDecisionListener::AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
39
    : m_challengeProxy(authenticationChallenge)
40
    : m_completionHandler(WTFMove(completionHandler))
40
{
41
{
41
}
42
}
42
43
43
void AuthenticationDecisionListener::useCredential(WebCredential* credential)
44
AuthenticationDecisionListener::~AuthenticationDecisionListener()
44
{
45
{
45
    if (m_challengeProxy)
46
    if (m_completionHandler)
46
        m_challengeProxy->useCredential(credential);
47
        m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
47
}
48
}
48
49
49
void AuthenticationDecisionListener::cancel()
50
void AuthenticationDecisionListener::useCredential(std::optional<WebCore::Credential>&& credential)
50
{
51
{
51
    if (m_challengeProxy)
52
    if (m_completionHandler)
52
        m_challengeProxy->cancel();
53
        m_completionHandler(AuthenticationChallengeDisposition::UseCredential, WTFMove(credential));
53
}
54
}
54
55
55
void AuthenticationDecisionListener::performDefaultHandling()
56
void AuthenticationDecisionListener::cancel()
56
{
57
{
57
    if (m_challengeProxy)
58
    if (m_completionHandler)
58
        m_challengeProxy->performDefaultHandling();
59
        m_completionHandler(AuthenticationChallengeDisposition::Cancel, std::nullopt);
59
}
60
}
60
61
61
void AuthenticationDecisionListener::rejectProtectionSpaceAndContinue()
62
void AuthenticationDecisionListener::performDefaultHandling()
62
{
63
{
63
    if (m_challengeProxy)
64
    if (m_completionHandler)
64
        m_challengeProxy->rejectProtectionSpaceAndContinue();
65
        m_completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, std::nullopt);
65
}
66
}
66
67
67
void AuthenticationDecisionListener::detachChallenge()
68
void AuthenticationDecisionListener::rejectProtectionSpaceAndContinue()
68
{
69
{
69
    m_challengeProxy = 0;
70
    if (m_completionHandler)
71
        m_completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpaceAndContinue, std::nullopt);
70
}
72
}
71
    
73
    
72
} // namespace WebKit
74
} // namespace WebKit
- Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.h -13 / +13 lines
Lines 23-60 Source/WebKit/UIProcess/Authentication/AuthenticationDecisionListener.h_sec1
23
 * THE POSSIBILITY OF SUCH DAMAGE.
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
#ifndef AuthenticationDecisionListener_h
26
#pragma once
27
#define AuthenticationDecisionListener_h
28
27
29
#include "APIObject.h"
28
#include "APIObject.h"
30
29
31
#include <wtf/RefPtr.h>
30
#include <wtf/CompletionHandler.h>
31
32
namespace WebCore {
33
class Credential;
34
}
32
35
33
namespace WebKit {
36
namespace WebKit {
34
37
38
enum class AuthenticationChallengeDisposition;
35
class AuthenticationChallengeProxy;
39
class AuthenticationChallengeProxy;
36
class WebCredential;
37
40
38
class AuthenticationDecisionListener : public API::ObjectImpl<API::Object::Type::AuthenticationDecisionListener> {
41
class AuthenticationDecisionListener : public API::ObjectImpl<API::Object::Type::AuthenticationDecisionListener> {
39
public:
42
public:
40
    static Ref<AuthenticationDecisionListener> create(AuthenticationChallengeProxy* authenticationChallenge)
43
    static Ref<AuthenticationDecisionListener> create(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&& completionHandler)
41
    {
44
    {
42
        return adoptRef(*new AuthenticationDecisionListener(authenticationChallenge));
45
        return adoptRef(*new AuthenticationDecisionListener(WTFMove(completionHandler)));
43
    }
46
    }
47
    ~AuthenticationDecisionListener();
44
    
48
    
45
    void useCredential(WebCredential*);
49
    void useCredential(std::optional<WebCore::Credential>&&);
46
    void cancel();
50
    void cancel();
47
    void performDefaultHandling();
51
    void performDefaultHandling();
48
    void rejectProtectionSpaceAndContinue();
52
    void rejectProtectionSpaceAndContinue();
49
53
50
    void detachChallenge();
51
52
private:
54
private:
53
    explicit AuthenticationDecisionListener(AuthenticationChallengeProxy*);
55
    explicit AuthenticationDecisionListener(CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)>&&);
54
56
55
    AuthenticationChallengeProxy* m_challengeProxy;
57
    CompletionHandler<void(AuthenticationChallengeDisposition, std::optional<WebCore::Credential>&&)> m_completionHandler;
56
};
58
};
57
59
58
} // namespace WebKit
60
} // namespace WebKit
59
60
#endif // WebAuthenticationDecisionListener_h
- Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm -5 / +4 lines
Lines 36-50 Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm_sec1
36
36
37
namespace WebKit {
37
namespace WebKit {
38
38
39
void AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc(uint64_t challengeID, const WebCore::Credential& credential) const
39
void AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc(IPC::Connection& connection, SecKeyProxyStore& secKeyProxyStore, uint64_t challengeID, const WebCore::Credential& credential)
40
{
40
{
41
    ASSERT(m_secKeyProxyStore);
41
    ASSERT(secKeyProxyStore.isInitialized());
42
    ASSERT(m_secKeyProxyStore->isInitialized());
43
42
44
    auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
43
    auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
45
    xpc_dictionary_set_string(message.get(), clientCertificateAuthenticationXPCMessageNameKey, clientCertificateAuthenticationXPCMessageNameValue);
44
    xpc_dictionary_set_string(message.get(), clientCertificateAuthenticationXPCMessageNameKey, clientCertificateAuthenticationXPCMessageNameValue);
46
    xpc_dictionary_set_uint64(message.get(), clientCertificateAuthenticationXPCChallengeIDKey, challengeID);
45
    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);
48
    auto certificateDataArray = adoptOSObject(xpc_array_create(nullptr, 0));
47
    auto certificateDataArray = adoptOSObject(xpc_array_create(nullptr, 0));
49
    for (id certificate in credential.nsCredential().certificates) {
48
    for (id certificate in credential.nsCredential().certificates) {
50
        auto data = adoptCF(SecCertificateCopyData((SecCertificateRef)certificate));
49
        auto data = adoptCF(SecCertificateCopyData((SecCertificateRef)certificate));
Lines 53-59 void AuthenticationChallengeProxy::sendC Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm_sec2
53
    xpc_dictionary_set_value(message.get(), clientCertificateAuthenticationXPCCertificatesKey, certificateDataArray.get());
52
    xpc_dictionary_set_value(message.get(), clientCertificateAuthenticationXPCCertificatesKey, certificateDataArray.get());
54
    xpc_dictionary_set_uint64(message.get(), clientCertificateAuthenticationXPCPersistenceKey, static_cast<uint64_t>(credential.nsCredential().persistence));
53
    xpc_dictionary_set_uint64(message.get(), clientCertificateAuthenticationXPCPersistenceKey, static_cast<uint64_t>(credential.nsCredential().persistence));
55
54
56
    xpc_connection_send_message(m_connection->xpcConnection(), message.get());
55
    xpc_connection_send_message(connection.xpcConnection(), message.get());
57
}
56
}
58
57
59
} // namespace WebKit
58
} // namespace WebKit
- Source/WebKit/UIProcess/Cocoa/DownloadClient.mm -11 / +8 lines
Lines 122-128 void DownloadClient::didReceiveAuthentic Source/WebKit/UIProcess/Cocoa/DownloadClient.mm_sec1
122
{
122
{
123
    // FIXME: System Preview needs code here.
123
    // FIXME: System Preview needs code here.
124
    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
124
    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
125
        authenticationChallenge.listener()->performDefaultHandling();
125
        authenticationChallenge.listener().performDefaultHandling();
126
        return;
126
        return;
127
    }
127
    }
128
128
Lines 131-155 void DownloadClient::didReceiveAuthentic Source/WebKit/UIProcess/Cocoa/DownloadClient.mm_sec2
131
            return;
131
            return;
132
        checker->didCallCompletionHandler();
132
        checker->didCallCompletionHandler();
133
        switch (disposition) {
133
        switch (disposition) {
134
        case NSURLSessionAuthChallengeUseCredential: {
134
        case NSURLSessionAuthChallengeUseCredential:
135
            RefPtr<WebCredential> webCredential;
136
            if (credential)
135
            if (credential)
137
                webCredential = WebCredential::create(WebCore::Credential(credential));
136
                authenticationChallenge->listener().useCredential(WebCore::Credential(credential));
138
            
137
            else
139
            authenticationChallenge->listener()->useCredential(webCredential.get());
138
                authenticationChallenge->listener().useCredential(std::nullopt);
140
            break;
139
            break;
141
        }
142
            
143
        case NSURLSessionAuthChallengePerformDefaultHandling:
140
        case NSURLSessionAuthChallengePerformDefaultHandling:
144
            authenticationChallenge->listener()->performDefaultHandling();
141
            authenticationChallenge->listener().performDefaultHandling();
145
            break;
142
            break;
146
            
143
            
147
        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
144
        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
148
            authenticationChallenge->listener()->cancel();
145
            authenticationChallenge->listener().cancel();
149
            break;
146
            break;
150
            
147
            
151
        case NSURLSessionAuthChallengeRejectProtectionSpace:
148
        case NSURLSessionAuthChallengeRejectProtectionSpace:
152
            authenticationChallenge->listener()->rejectProtectionSpaceAndContinue();
149
            authenticationChallenge->listener().rejectProtectionSpaceAndContinue();
153
            break;
150
            break;
154
            
151
            
155
        default:
152
        default:
- Source/WebKit/UIProcess/Cocoa/NavigationState.mm -12 / +9 lines
Lines 852-862 void NavigationState::NavigationClient:: Source/WebKit/UIProcess/Cocoa/NavigationState.mm_sec1
852
void NavigationState::NavigationClient::didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy& authenticationChallenge)
852
void NavigationState::NavigationClient::didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy& authenticationChallenge)
853
{
853
{
854
    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
854
    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
855
        return authenticationChallenge.performDefaultHandling();
855
        return authenticationChallenge.listener().performDefaultHandling();
856
856
857
    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
857
    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
858
    if (!navigationDelegate)
858
    if (!navigationDelegate)
859
        return authenticationChallenge.performDefaultHandling();
859
        return authenticationChallenge.listener().performDefaultHandling();
860
860
861
    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
861
    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
862
    [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) {
862
    [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) {
Lines 865-889 void NavigationState::NavigationClient:: Source/WebKit/UIProcess/Cocoa/NavigationState.mm_sec2
865
        checker->didCallCompletionHandler();
865
        checker->didCallCompletionHandler();
866
866
867
        switch (disposition) {
867
        switch (disposition) {
868
        case NSURLSessionAuthChallengeUseCredential: {
868
        case NSURLSessionAuthChallengeUseCredential:
869
            RefPtr<WebCredential> webCredential;
870
            if (credential)
869
            if (credential)
871
                webCredential = WebCredential::create(WebCore::Credential(credential));
870
                challenge->listener().useCredential(Credential(credential));
872
871
            else
873
            challenge->useCredential(webCredential.get());
872
                challenge->listener().useCredential(std::nullopt);
874
            break;
873
            break;
875
        }
876
877
        case NSURLSessionAuthChallengePerformDefaultHandling:
874
        case NSURLSessionAuthChallengePerformDefaultHandling:
878
            challenge->performDefaultHandling();
875
            challenge->listener().performDefaultHandling();
879
            break;
876
            break;
880
877
881
        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
878
        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
882
            challenge->cancel();
879
            challenge->listener().cancel();
883
            break;
880
            break;
884
881
885
        case NSURLSessionAuthChallengeRejectProtectionSpace:
882
        case NSURLSessionAuthChallengeRejectProtectionSpace:
886
            challenge->rejectProtectionSpaceAndContinue();
883
            challenge->listener().rejectProtectionSpaceAndContinue();
887
            break;
884
            break;
888
885
889
        default:
886
        default:
- Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp -1 / +1 lines
Lines 120-126 void DownloadProxy::didReceiveAuthentica Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp_sec1
120
    if (!m_processPool)
120
    if (!m_processPool)
121
        return;
121
        return;
122
122
123
    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, m_processPool->networkingProcessConnection());
123
    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, makeRef(*m_processPool->networkingProcessConnection()), nullptr);
124
124
125
    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
125
    m_processPool->downloadClient().didReceiveAuthenticationChallenge(*m_processPool, *this, authenticationChallengeProxy.get());
126
}
126
}
- Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp -2 / +2 lines
Lines 294-300 void NetworkProcessProxy::didReceiveAuth Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp_sec1
294
{
294
{
295
#if ENABLE(SERVICE_WORKER)
295
#if ENABLE(SERVICE_WORKER)
296
    if (auto* serviceWorkerProcessProxy = m_processPool.serviceWorkerProcessProxyFromPageID(pageID)) {
296
    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);
298
        serviceWorkerProcessProxy->didReceiveAuthenticationChallenge(pageID, frameID, WTFMove(authenticationChallenge));
298
        serviceWorkerProcessProxy->didReceiveAuthenticationChallenge(pageID, frameID, WTFMove(authenticationChallenge));
299
        return;
299
        return;
300
    }
300
    }
Lines 303-309 void NetworkProcessProxy::didReceiveAuth Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp_sec2
303
    WebPageProxy* page = WebProcessProxy::webPage(pageID);
303
    WebPageProxy* page = WebProcessProxy::webPage(pageID);
304
    MESSAGE_CHECK(page);
304
    MESSAGE_CHECK(page);
305
305
306
    auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, connection());
306
    auto authenticationChallenge = AuthenticationChallengeProxy::create(WTFMove(coreChallenge), challengeID, makeRef(*connection()), page->secKeyProxyStore(coreChallenge));
307
    page->didReceiveAuthenticationChallengeProxy(frameID, WTFMove(authenticationChallenge));
307
    page->didReceiveAuthenticationChallengeProxy(frameID, WTFMove(authenticationChallenge));
308
}
308
}
309
309

Return to Bug 189668