Changeset 220854 in webkit


Ignore:
Timestamp:
Aug 17, 2017 6:13:32 AM (7 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220829 r220854  
     12017-08-17  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Add NTLM authentication enabled API
     4        https://bugs.webkit.org/show_bug.cgi?id=122952
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add/remove NTLM feature to/from soup session depending on whether the feature is enabled or disabled.
     9
     10        * platform/network/soup/SoupNetworkSession.cpp:
     11        (WebCore::SoupNetworkSession::SoupNetworkSession):
     12        (WebCore::SoupNetworkSession::setInitialNTLMAuthenticationEnabled):
     13        (WebCore::SoupNetworkSession::setNTLMAuthenticationEnabled):
     14        * platform/network/soup/SoupNetworkSession.h:
     15
    1162017-08-16  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp

    r219954 r220854  
    4747
    4848static bool gIgnoreTLSErrors;
     49static bool gInitialNTLMAuthenticationEnabled;
    4950static CString gInitialAcceptLanguages;
    5051static SoupNetworkProxySettings gProxySettings;
     
    146147    if (!gInitialAcceptLanguages.isNull())
    147148        setAcceptLanguages(gInitialAcceptLanguages);
     149
     150    if (gInitialNTLMAuthenticationEnabled)
     151        soup_session_add_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
    148152
    149153#if SOUP_CHECK_VERSION(2, 53, 92)
     
    324328}
    325329
     330void SoupNetworkSession::setInitialNTLMAuthenticationEnabled(bool enabled)
     331{
     332    gInitialNTLMAuthenticationEnabled = enabled;
     333}
     334
     335void SoupNetworkSession::setNTLMAuthenticationEnabled(bool enabled)
     336{
     337    if (enabled)
     338        soup_session_add_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
     339    else
     340        soup_session_remove_feature_by_type(m_soupSession.get(), SOUP_TYPE_AUTH_NTLM);
     341}
     342
    326343} // namespace WebCore
    327344
  • trunk/Source/WebCore/platform/network/soup/SoupNetworkSession.h

    r218799 r220854  
    7171    void setupCustomProtocols();
    7272
     73    static void setInitialNTLMAuthenticationEnabled(bool);
     74    void setNTLMAuthenticationEnabled(bool);
     75
    7376private:
    7477    void setupLogger();
  • trunk/Source/WebKit/ChangeLog

    r220821 r220854  
     12017-08-17  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Add NTLM authentication enabled API
     4        https://bugs.webkit.org/show_bug.cgi?id=122952
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add API to WebKitWebContext to enable/disable NTLM authentication.
     9
     10        * NetworkProcess/NetworkProcess.h:
     11        * NetworkProcess/NetworkProcess.messages.in:
     12        * NetworkProcess/NetworkProcessCreationParameters.cpp:
     13        (WebKit::NetworkProcessCreationParameters::encode const):
     14        (WebKit::NetworkProcessCreationParameters::decode):
     15        * NetworkProcess/NetworkProcessCreationParameters.h:
     16        * NetworkProcess/soup/NetworkProcessSoup.cpp:
     17        (WebKit::NetworkProcess::platformInitializeNetworkProcess):
     18        (WebKit::NetworkProcess::setNTLMAuthenticationEnabled):
     19        * UIProcess/API/glib/WebKitWebContext.cpp:
     20        (webkit_web_context_get_ntlm_authentication_enabled):
     21        (webkit_web_context_set_ntlm_authentication_enabled):
     22        * UIProcess/API/gtk/WebKitWebContext.h:
     23        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
     24        * UIProcess/API/wpe/WebKitWebContext.h:
     25        * UIProcess/WebProcessPool.h:
     26        * UIProcess/soup/WebProcessPoolSoup.cpp:
     27        (WebKit::WebProcessPool::setNTLMAuthenticationEnabled):
     28
    1292017-08-16  Andy Estes  <aestes@apple.com>
    230
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r220267 r220854  
    211211    void userPreferredLanguagesChanged(const Vector<String>&);
    212212    void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&);
     213    void setNTLMAuthenticationEnabled(bool);
    213214#endif
    214215
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r220105 r220854  
    3232    UserPreferredLanguagesChanged(Vector<String> languages)
    3333    SetNetworkProxySettings(struct WebCore::SoupNetworkProxySettings settings)
     34    SetNTLMAuthenticationEnabled(bool enabled)
    3435#endif
    3536
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp

    r219050 r220854  
    9191    encoder.encodeEnum(cookieAcceptPolicy);
    9292    encoder << ignoreTLSErrors;
     93    encoder << ntlmAuthenticationEnabled;
    9394    encoder << languages;
    9495    encoder << proxySettings;
     
    189190    if (!decoder.decode(result.ignoreTLSErrors))
    190191        return false;
     192    if (!decoder.decode(result.ntlmAuthenticationEnabled))
     193        return false;
    191194    if (!decoder.decode(result.languages))
    192195        return false;
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h

    r219050 r220854  
    103103    HTTPCookieAcceptPolicy cookieAcceptPolicy { HTTPCookieAcceptPolicyAlways };
    104104    bool ignoreTLSErrors { false };
     105    bool ntlmAuthenticationEnabled { false };
    105106    Vector<String> languages;
    106107    WebCore::SoupNetworkProxySettings proxySettings;
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp

    r220267 r220854  
    133133
    134134    setIgnoreTLSErrors(parameters.ignoreTLSErrors);
     135    setNTLMAuthenticationEnabled(parameters.ntlmAuthenticationEnabled);
    135136}
    136137
     
    147148{
    148149    SoupNetworkSession::allowSpecificHTTPSCertificateForHost(certificateInfo, host);
     150}
     151
     152void NetworkProcess::setNTLMAuthenticationEnabled(bool enabled)
     153{
     154    SoupNetworkSession::setInitialNTLMAuthenticationEnabled(enabled);
     155    NetworkStorageSession::forEach([enabled](const NetworkStorageSession& session) {
     156        if (auto* soupSession = session.soupNetworkSession())
     157            soupSession->setNTLMAuthenticationEnabled(enabled);
     158    });
    149159}
    150160
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp

    r220387 r220854  
    15471547}
    15481548
     1549/**
     1550 * webkit_web_context_get_ntlm_authentication_enabled:
     1551 * @context: a #WebKitWebContext
     1552 *
     1553 * Get whether NTLM authentication is currently enabled. By default, the feature
     1554 * is disabled, and you need to call webkit_web_context_set_ntlm_authentication_enabled()
     1555 * to enable it.
     1556 *
     1557 * Returns: %TRUE if NTLM authentication is enabled, or %FALSE otherwise.
     1558 *
     1559 * Since: 2.18
     1560 */
     1561gboolean webkit_web_context_get_ntlm_authentication_enabled(WebKitWebContext* context)
     1562{
     1563    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE);
     1564
     1565    return context->priv->processPool->ntlmAuthenticationEnabled();
     1566}
     1567
     1568/**
     1569 * webkit_web_context_set_ntlm_authentication_enabled:
     1570 * @context: a #WebKitWebContext
     1571 * @enabled: Value to be set
     1572 *
     1573 * Enable or disable NTLM authentication.
     1574 *
     1575 * Since: 2.18
     1576 */
     1577void webkit_web_context_set_ntlm_authentication_enabled(WebKitWebContext* context, gboolean enabled)
     1578{
     1579    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     1580
     1581    return context->priv->processPool->setNTLMAuthenticationEnabled(enabled);
     1582}
     1583
    15491584void webkitWebContextInitializeNotificationPermissions(WebKitWebContext* context)
    15501585{
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebContext.h

    r216006 r220854  
    307307                                                     GList                         *disallowed_origins);
    308308
     309WEBKIT_API gboolean
     310webkit_web_context_get_ntlm_authentication_enabled  (WebKitWebContext              *context);
     311
     312WEBKIT_API void
     313webkit_web_context_set_ntlm_authentication_enabled  (WebKitWebContext              *context,
     314                                                     gboolean                       enabled);
     315
    309316G_END_DECLS
    310317
  • trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt

    r220329 r220854  
    6767webkit_web_context_set_process_model
    6868webkit_web_context_initialize_notification_permissions
     69webkit_web_context_get_ntlm_authentication_enabled
     70webkit_web_context_set_ntlm_authentication_enabled
    6971
    7072<SUBSECTION URI Scheme>
  • trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebContext.h

    r218553 r220854  
    307307                                                     GList                         *disallowed_origins);
    308308
     309WEBKIT_API gboolean
     310webkit_web_context_get_ntlm_authentication_enabled  (WebKitWebContext              *context);
     311
     312WEBKIT_API void
     313webkit_web_context_set_ntlm_authentication_enabled  (WebKitWebContext              *context,
     314                                                     gboolean                       enabled);
     315
    309316G_END_DECLS
    310317
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r220412 r220854  
    227227
    228228#if USE(SOUP)
     229    void setIgnoreTLSErrors(bool);
     230    bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
    229231    void setInitialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { m_initialHTTPCookieAcceptPolicy = policy; }
    230232    void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&);
     233    void setNTLMAuthenticationEnabled(bool);
     234    bool ntlmAuthenticationEnabled() const { return m_ntlmAuthenticationEnabled; }
    231235#endif
    232236    void setEnhancedAccessibility(bool);
     
    326330    static void willStartUsingPrivateBrowsing();
    327331    static void willStopUsingPrivateBrowsing();
    328 
    329 #if USE(SOUP)
    330     void setIgnoreTLSErrors(bool);
    331     bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
    332 #endif
    333332
    334333    static void setInvalidMessageCallback(void (*)(WKStringRef));
     
    528527    HTTPCookieAcceptPolicy m_initialHTTPCookieAcceptPolicy { HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain };
    529528    WebCore::SoupNetworkProxySettings m_networkProxySettings;
     529    bool m_ignoreTLSErrors { true };
     530    bool m_ntlmAuthenticationEnabled { false };
    530531#endif
    531532    HashSet<String, ASCIICaseInsensitiveHash> m_urlSchemesRegisteredForCustomProtocols;
     
    555556    HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
    556557    HashMap<uint64_t, RefPtr<StatisticsRequest>> m_statisticsRequests;
    557 
    558 #if USE(SOUP)
    559     bool m_ignoreTLSErrors { true };
    560 #endif
    561558
    562559    bool m_memoryCacheDisabled;
  • trunk/Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp

    r213927 r220854  
    6262}
    6363
     64void WebProcessPool::setNTLMAuthenticationEnabled(bool enabled)
     65{
     66    if (m_ntlmAuthenticationEnabled == enabled)
     67        return;
     68
     69    m_ntlmAuthenticationEnabled = enabled;
     70    if (m_networkProcess)
     71        m_networkProcess->send(Messages::NetworkProcess::SetNTLMAuthenticationEnabled(m_ntlmAuthenticationEnabled), 0);
    6472}
     73
     74}
  • trunk/Tools/ChangeLog

    r220809 r220854  
     12017-08-17  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Add NTLM authentication enabled API
     4        https://bugs.webkit.org/show_bug.cgi?id=122952
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add a test case to check we can enable/disable NTLM.
     9
     10        * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
     11        (testWebViewAuthenticationNTLM):
     12        (beforeAll):
     13
    1142017-08-16  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp

    r220583 r220854  
    251251    g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished);
    252252    g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, authExpectedSuccessTitle);
     253}
     254
     255static void testWebViewAuthenticationNTLM(AuthenticationTest* test, gconstpointer)
     256{
     257    // NTML is disabled by default.
     258    g_assert(!webkit_web_context_get_ntlm_authentication_enabled(test->m_webContext.get()));
     259    webkit_web_context_set_ntlm_authentication_enabled(test->m_webContext.get(), TRUE);
     260    g_assert(webkit_web_context_get_ntlm_authentication_enabled(test->m_webContext.get()));
     261
     262    // FIXME: can we test NTLM authentication?
    253263}
    254264
     
    419429    AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
    420430    AuthenticationTest::add("WebKitWebView", "authentication-empty-realm", testWebViewAuthenticationEmptyRealm);
     431    AuthenticationTest::add("WebKitWebView", "authentication-ntlm", testWebViewAuthenticationNTLM);
    421432    ProxyAuthenticationTest::add("WebKitWebView", "authentication-proxy", testWebViewAuthenticationProxy);
    422433    ProxyAuthenticationTest::add("WebKitWebView", "authentication-proxy-https", testWebViewAuthenticationProxyHTTPS);
Note: See TracChangeset for help on using the changeset viewer.