Commit 30aa9c7b authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen Committed by Liang Qi
Browse files

Create a net::HttpAuthHandlerRegistryFactory like Chromium


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: default avatarMichal Klocek <michal.klocek@qt.io>
Reviewed-by: default avatarKai Koehne <kai.koehne@qt.io>
Showing with 20 additions and 1 deletion
......@@ -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|.
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment