Title: [220854] trunk
Revision
220854
Author
[email protected]
Date
2017-08-17 06:13:32 -0700 (Thu, 17 Aug 2017)

Log Message

[GTK][WPE] Add NTLM authentication enabled API
https://bugs.webkit.org/show_bug.cgi?id=122952

Reviewed by Michael Catanzaro.

Source/WebCore:

Add/remove NTLM feature to/from soup session depending on whether the feature is enabled or disabled.

* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::SoupNetworkSession::SoupNetworkSession):
(WebCore::SoupNetworkSession::setInitialNTLMAuthenticationEnabled):
(WebCore::SoupNetworkSession::setNTLMAuthenticationEnabled):
* platform/network/soup/SoupNetworkSession.h:

Source/WebKit:

Add API to WebKitWebContext to enable/disable NTLM authentication.

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
(WebKit::NetworkProcess::setNTLMAuthenticationEnabled):
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkit_web_context_get_ntlm_authentication_enabled):
(webkit_web_context_set_ntlm_authentication_enabled):
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/wpe/WebKitWebContext.h:
* UIProcess/WebProcessPool.h:
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::WebProcessPool::setNTLMAuthenticationEnabled):

Tools:

Add a test case to check we can enable/disable NTLM.

* TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
(testWebViewAuthenticationNTLM):
(beforeAll):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (220853 => 220854)


--- trunk/Source/WebCore/ChangeLog	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebCore/ChangeLog	2017-08-17 13:13:32 UTC (rev 220854)
@@ -1,3 +1,18 @@
+2017-08-17  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Add NTLM authentication enabled API
+        https://bugs.webkit.org/show_bug.cgi?id=122952
+
+        Reviewed by Michael Catanzaro.
+
+        Add/remove NTLM feature to/from soup session depending on whether the feature is enabled or disabled.
+
+        * platform/network/soup/SoupNetworkSession.cpp:
+        (WebCore::SoupNetworkSession::SoupNetworkSession):
+        (WebCore::SoupNetworkSession::setInitialNTLMAuthenticationEnabled):
+        (WebCore::SoupNetworkSession::setNTLMAuthenticationEnabled):
+        * platform/network/soup/SoupNetworkSession.h:
+
 2017-08-16  Ryosuke Niwa  <[email protected]>
 
         Add the support for mutating clipboard data via DataTransferItemList

Modified: trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp (220853 => 220854)


--- trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -46,6 +46,7 @@
 namespace WebCore {
 
 static bool gIgnoreTLSErrors;
+static bool gInitialNTLMAuthenticationEnabled;
 static CString gInitialAcceptLanguages;
 static SoupNetworkProxySettings gProxySettings;
 static GType gCustomProtocolRequestType;
@@ -146,6 +147,9 @@
     if (!gInitialAcceptLanguages.isNull())
         setAcceptLanguages(gInitialAcceptLanguages);
 
+    if (gInitialNTLMAuthenticationEnabled)
+        soup_session_add_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
+
 #if SOUP_CHECK_VERSION(2, 53, 92)
     if (soup_auth_negotiate_supported()) {
         g_object_set(m_soupSession.get(),
@@ -323,6 +327,19 @@
     clientCertificates().add(host, HostTLSCertificateSet()).iterator->value.add(certificateInfo.certificate());
 }
 
+void SoupNetworkSession::setInitialNTLMAuthenticationEnabled(bool enabled)
+{
+    gInitialNTLMAuthenticationEnabled = enabled;
+}
+
+void SoupNetworkSession::setNTLMAuthenticationEnabled(bool enabled)
+{
+    if (enabled)
+        soup_session_add_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
+    else
+        soup_session_remove_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
+}
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h (220853 => 220854)


--- trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -70,6 +70,9 @@
     static void setCustomProtocolRequestType(GType);
     void setupCustomProtocols();
 
+    static void setInitialNTLMAuthenticationEnabled(bool);
+    void setNTLMAuthenticationEnabled(bool);
+
 private:
     void setupLogger();
 

Modified: trunk/Source/WebKit/ChangeLog (220853 => 220854)


--- trunk/Source/WebKit/ChangeLog	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/ChangeLog	2017-08-17 13:13:32 UTC (rev 220854)
@@ -1,3 +1,31 @@
+2017-08-17  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Add NTLM authentication enabled API
+        https://bugs.webkit.org/show_bug.cgi?id=122952
+
+        Reviewed by Michael Catanzaro.
+
+        Add API to WebKitWebContext to enable/disable NTLM authentication.
+
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode const):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * NetworkProcess/soup/NetworkProcessSoup.cpp:
+        (WebKit::NetworkProcess::platformInitializeNetworkProcess):
+        (WebKit::NetworkProcess::setNTLMAuthenticationEnabled):
+        * UIProcess/API/glib/WebKitWebContext.cpp:
+        (webkit_web_context_get_ntlm_authentication_enabled):
+        (webkit_web_context_set_ntlm_authentication_enabled):
+        * UIProcess/API/gtk/WebKitWebContext.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+        * UIProcess/API/wpe/WebKitWebContext.h:
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/soup/WebProcessPoolSoup.cpp:
+        (WebKit::WebProcessPool::setNTLMAuthenticationEnabled):
+
 2017-08-16  Andy Estes  <[email protected]>
 
         [Apple Pay] Rename PaymentRequest to ApplePaySessionPaymentRequest

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (220853 => 220854)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -210,6 +210,7 @@
     void setIgnoreTLSErrors(bool);
     void userPreferredLanguagesChanged(const Vector<String>&);
     void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&);
+    void setNTLMAuthenticationEnabled(bool);
 #endif
 
     // Platform Helpers

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (220853 => 220854)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2017-08-17 13:13:32 UTC (rev 220854)
@@ -31,6 +31,7 @@
     SetIgnoreTLSErrors(bool ignoreTLSErrors)
     UserPreferredLanguagesChanged(Vector<String> languages)
     SetNetworkProxySettings(struct WebCore::SoupNetworkProxySettings settings)
+    SetNTLMAuthenticationEnabled(bool enabled)
 #endif
 
     ClearCachedCredentials()

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp (220853 => 220854)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -90,6 +90,7 @@
     encoder << cookiePersistentStorageType;
     encoder.encodeEnum(cookieAcceptPolicy);
     encoder << ignoreTLSErrors;
+    encoder << ntlmAuthenticationEnabled;
     encoder << languages;
     encoder << proxySettings;
 #endif
@@ -188,6 +189,8 @@
         return false;
     if (!decoder.decode(result.ignoreTLSErrors))
         return false;
+    if (!decoder.decode(result.ntlmAuthenticationEnabled))
+        return false;
     if (!decoder.decode(result.languages))
         return false;
     if (!decoder.decode(result.proxySettings))

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h (220853 => 220854)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -102,6 +102,7 @@
     uint32_t cookiePersistentStorageType { 0 };
     HTTPCookieAcceptPolicy cookieAcceptPolicy { HTTPCookieAcceptPolicyAlways };
     bool ignoreTLSErrors { false };
+    bool ntlmAuthenticationEnabled { false };
     Vector<String> languages;
     WebCore::SoupNetworkProxySettings proxySettings;
 #endif

Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp (220853 => 220854)


--- trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -132,6 +132,7 @@
         userPreferredLanguagesChanged(parameters.languages);
 
     setIgnoreTLSErrors(parameters.ignoreTLSErrors);
+    setNTLMAuthenticationEnabled(parameters.ntlmAuthenticationEnabled);
 }
 
 void NetworkProcess::platformSetURLCacheSize(unsigned, uint64_t)
@@ -148,6 +149,15 @@
     SoupNetworkSession::allowSpecificHTTPSCertificateForHost(certificateInfo, host);
 }
 
+void NetworkProcess::setNTLMAuthenticationEnabled(bool enabled)
+{
+    SoupNetworkSession::setInitialNTLMAuthenticationEnabled(enabled);
+    NetworkStorageSession::forEach([enabled](const NetworkStorageSession& session) {
+        if (auto* soupSession = session.soupNetworkSession())
+            soupSession->setNTLMAuthenticationEnabled(enabled);
+    });
+}
+
 void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear)
 {
     if (cachesToClear == InMemoryResourceCachesOnly)

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -1546,6 +1546,41 @@
     context->priv->notificationProvider->setNotificationPermissions(WTFMove(map));
 }
 
+/**
+ * webkit_web_context_get_ntlm_authentication_enabled:
+ * @context: a #WebKitWebContext
+ *
+ * Get whether NTLM authentication is currently enabled. By default, the feature
+ * is disabled, and you need to call webkit_web_context_set_ntlm_authentication_enabled()
+ * to enable it.
+ *
+ * Returns: %TRUE if NTLM authentication is enabled, or %FALSE otherwise.
+ *
+ * Since: 2.18
+ */
+gboolean webkit_web_context_get_ntlm_authentication_enabled(WebKitWebContext* context)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE);
+
+    return context->priv->processPool->ntlmAuthenticationEnabled();
+}
+
+/**
+ * webkit_web_context_set_ntlm_authentication_enabled:
+ * @context: a #WebKitWebContext
+ * @enabled: Value to be set
+ *
+ * Enable or disable NTLM authentication.
+ *
+ * Since: 2.18
+ */
+void webkit_web_context_set_ntlm_authentication_enabled(WebKitWebContext* context, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+    return context->priv->processPool->setNTLMAuthenticationEnabled(enabled);
+}
+
 void webkitWebContextInitializeNotificationPermissions(WebKitWebContext* context)
 {
     g_signal_emit(context, signals[INITIALIZE_NOTIFICATION_PERMISSIONS], 0);

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -306,6 +306,13 @@
                                                      GList                         *allowed_origins,
                                                      GList                         *disallowed_origins);
 
+WEBKIT_API gboolean
+webkit_web_context_get_ntlm_authentication_enabled  (WebKitWebContext              *context);
+
+WEBKIT_API void
+webkit_web_context_set_ntlm_authentication_enabled  (WebKitWebContext              *context,
+                                                     gboolean                       enabled);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2017-08-17 13:13:32 UTC (rev 220854)
@@ -66,6 +66,8 @@
 webkit_web_context_get_process_model
 webkit_web_context_set_process_model
 webkit_web_context_initialize_notification_permissions
+webkit_web_context_get_ntlm_authentication_enabled
+webkit_web_context_set_ntlm_authentication_enabled
 
 <SUBSECTION URI Scheme>
 WebKitURISchemeRequestCallback

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -306,6 +306,13 @@
                                                      GList                         *allowed_origins,
                                                      GList                         *disallowed_origins);
 
+WEBKIT_API gboolean
+webkit_web_context_get_ntlm_authentication_enabled  (WebKitWebContext              *context);
+
+WEBKIT_API void
+webkit_web_context_set_ntlm_authentication_enabled  (WebKitWebContext              *context,
+                                                     gboolean                       enabled);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2017-08-17 13:13:32 UTC (rev 220854)
@@ -226,8 +226,12 @@
     void stopMemorySampler();
 
 #if USE(SOUP)
+    void setIgnoreTLSErrors(bool);
+    bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
     void setInitialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { m_initialHTTPCookieAcceptPolicy = policy; }
     void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&);
+    void setNTLMAuthenticationEnabled(bool);
+    bool ntlmAuthenticationEnabled() const { return m_ntlmAuthenticationEnabled; }
 #endif
     void setEnhancedAccessibility(bool);
     
@@ -326,11 +330,6 @@
     static void willStartUsingPrivateBrowsing();
     static void willStopUsingPrivateBrowsing();
 
-#if USE(SOUP)
-    void setIgnoreTLSErrors(bool);
-    bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
-#endif
-
     static void setInvalidMessageCallback(void (*)(WKStringRef));
     static void didReceiveInvalidMessage(const IPC::StringReference& messageReceiverName, const IPC::StringReference& messageName);
 
@@ -527,6 +526,8 @@
 #if USE(SOUP)
     HTTPCookieAcceptPolicy m_initialHTTPCookieAcceptPolicy { HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain };
     WebCore::SoupNetworkProxySettings m_networkProxySettings;
+    bool m_ignoreTLSErrors { true };
+    bool m_ntlmAuthenticationEnabled { false };
 #endif
     HashSet<String, ASCIICaseInsensitiveHash> m_urlSchemesRegisteredForCustomProtocols;
 
@@ -555,10 +556,6 @@
     HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
     HashMap<uint64_t, RefPtr<StatisticsRequest>> m_statisticsRequests;
 
-#if USE(SOUP)
-    bool m_ignoreTLSErrors { true };
-#endif
-
     bool m_memoryCacheDisabled;
     bool m_resourceLoadStatisticsEnabled { false };
     bool m_javaScriptConfigurationFileEnabled { false };

Modified: trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp (220853 => 220854)


--- trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -61,4 +61,14 @@
         m_networkProcess->send(Messages::NetworkProcess::SetNetworkProxySettings(m_networkProxySettings), 0);
 }
 
+void WebProcessPool::setNTLMAuthenticationEnabled(bool enabled)
+{
+    if (m_ntlmAuthenticationEnabled == enabled)
+        return;
+
+    m_ntlmAuthenticationEnabled = enabled;
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::NetworkProcess::SetNTLMAuthenticationEnabled(m_ntlmAuthenticationEnabled), 0);
 }
+
+}

Modified: trunk/Tools/ChangeLog (220853 => 220854)


--- trunk/Tools/ChangeLog	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Tools/ChangeLog	2017-08-17 13:13:32 UTC (rev 220854)
@@ -1,3 +1,16 @@
+2017-08-17  Carlos Garcia Campos  <[email protected]>
+
+        [GTK][WPE] Add NTLM authentication enabled API
+        https://bugs.webkit.org/show_bug.cgi?id=122952
+
+        Reviewed by Michael Catanzaro.
+
+        Add a test case to check we can enable/disable NTLM.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
+        (testWebViewAuthenticationNTLM):
+        (beforeAll):
+
 2017-08-16  Yoshiaki Jitsukawa  <[email protected]>
 
         [PAL] Move spi/ios and spi/win directories into PAL

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp (220853 => 220854)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2017-08-17 12:41:32 UTC (rev 220853)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp	2017-08-17 13:13:32 UTC (rev 220854)
@@ -252,6 +252,16 @@
     g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
 }
 
+static void testWebViewAuthenticationNTLM(AuthenticationTest* test, gconstpointer)
+{
+    // NTML is disabled by default.
+    g_assert(!webkit_web_context_get_ntlm_authentication_enabled(test->m_webContext.get()));
+    webkit_web_context_set_ntlm_authentication_enabled(test->m_webContext.get(), TRUE);
+    g_assert(webkit_web_context_get_ntlm_authentication_enabled(test->m_webContext.get()));
+
+    // FIXME: can we test NTLM authentication?
+}
+
 class Tunnel {
 public:
     Tunnel(SoupServer* server, SoupMessage* message)
@@ -418,6 +428,7 @@
     AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
     AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
     AuthenticationTest::add("WebKitWebView", "authentication-empty-realm", testWebViewAuthenticationEmptyRealm);
+    AuthenticationTest::add("WebKitWebView", "authentication-ntlm", testWebViewAuthenticationNTLM);
     ProxyAuthenticationTest::add("WebKitWebView", "authentication-proxy", testWebViewAuthenticationProxy);
     ProxyAuthenticationTest::add("WebKitWebView", "authentication-proxy-https", testWebViewAuthenticationProxyHTTPS);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to