summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-12 17:46:40 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-27 06:52:14 +0000
commit30aa9c7bf0f1eceda8516fd5de87dc8e2cff1758 (patch)
tree2c147a88b5f2663c2e7ef9404ef0cdf4861d3cac
parentf492500fbe148eb0732c9096e48f1e5f6392251c (diff)
Create a net::HttpAuthHandlerRegistryFactory like Chromiumv5.10.0-beta3
Instead of creating a "default" HttpAuthHandlerFactory, create a HttpAuthHandlerRegistryFactory which should have the ability to use multiple different authentication schemes, similar to what Chromium does. Task-number: QTBUG-57729 Change-Id: I4486e2280838b002a9badb6d4261676199045f4b Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--src/core/url_request_context_getter_qt.cpp19
-rw-r--r--src/core/url_request_context_getter_qt.h2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 4f1850f5..86f0c2b6 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -59,6 +59,8 @@
#include "net/dns/mapped_host_resolver.h"
#include "net/extras/sqlite/sqlite_channel_id_store.h"
#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_auth_preferences.h"
+#include "net/http/http_auth_scheme.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties_impl.h"
@@ -209,6 +211,13 @@ void URLRequestContextGetterQt::generateAllStorage()
m_updateAllStorage = false;
}
+static const char* const kDefaultAuthSchemes[] = { net::kBasicAuthScheme,
+ net::kDigestAuthScheme,
+#if defined(USE_KERBEROS) && !defined(OS_ANDROID)
+ net::kNegotiateAuthScheme,
+#endif
+ net::kNtlmAuthScheme };
+
void URLRequestContextGetterQt::generateStorage()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
@@ -251,7 +260,15 @@ void URLRequestContextGetterQt::generateStorage()
m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(new net::TransportSecurityState()));
- m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
+ if (!m_httpAuthPreferences) {
+ std::vector<std::string> auth_types(std::begin(kDefaultAuthSchemes), std::end(kDefaultAuthSchemes));
+ m_httpAuthPreferences.reset(new net::HttpAuthPreferences(auth_types
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ , std::string() /* gssapi library name */
+#endif
+ ));
+ }
+ m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerRegistryFactory::Create(m_httpAuthPreferences.get(), host_resolver.get()));
m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl));
// Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index 511d9eb0..495c9eb2 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -62,6 +62,7 @@
#include <QtCore/qsharedpointer.h>
namespace net {
+class HttpAuthPreferences;
class MappedHostResolver;
class ProxyConfigService;
}
@@ -126,6 +127,7 @@ private:
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
content::URLRequestInterceptorScopedVector m_requestInterceptors;
std::unique_ptr<net::HttpNetworkSession> m_httpNetworkSession;
+ std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
QList<QByteArray> m_installedCustomSchemes;
QWebEngineUrlRequestInterceptor* m_requestInterceptor;