Explicitly create HttpAuthHandlerFactory

The CreateDefault method does not set a URLSecurityManager, so the code will
fall-back to disabling all built-in authentication. Instead, use the default
URLSecurityManager which will use IE Security Zones on Windows to determine
whether a URL is part of the Local Intranet zone or on non-Windows, default
proxy rules will be used (i.e. would a default proxy map vs. connect direct).
This commit is contained in:
Paul Betts 2015-05-04 15:35:25 -07:00
parent 7e376c1f73
commit 9737ba3e37

View file

@ -21,6 +21,7 @@
#include "net/dns/mapped_host_resolver.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/url_security_manager.h"
#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
#include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_script_fetcher_impl.h"
@ -188,11 +189,27 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
NULL,
url_request_context_->network_delegate()));
auto url_sec_mgr = net::URLSecurityManager::Create(NULL, NULL);
std::vector<std::string> schemes;
schemes.push_back(std::string("basic"));
schemes.push_back(std::string("digest"));
schemes.push_back(std::string("ntlm"));
schemes.push_back(std::string("negotiate"));
auto auth_handler_factory =
net::HttpAuthHandlerRegistryFactory::Create(
schemes,
url_sec_mgr,
host_resolver.get(),
std::string(), // gssapi_library_name
false, // negotiate_disable_cname_lookup
true); // negotiate_enable_port
storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
storage_->set_transport_security_state(new net::TransportSecurityState);
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
storage_->set_http_auth_handler_factory(auth_handler_factory);
scoped_ptr<net::HttpServerProperties> server_properties(
new net::HttpServerPropertiesImpl);
storage_->set_http_server_properties(server_properties.Pass());