Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: net/http/http_auth_preferences.cc

Issue 1414313002: Allow dynamic updating of authentication policies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error on Windows and component build link error Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_auth_preferences.h ('k') | net/http/http_auth_preferences_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_preferences.cc
diff --git a/net/http/http_auth_preferences.cc b/net/http/http_auth_preferences.cc
new file mode 100644
index 0000000000000000000000000000000000000000..51d7fa5648775284f155244830cd67716b430768
--- /dev/null
+++ b/net/http/http_auth_preferences.cc
@@ -0,0 +1,118 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/prefs/pref_service.h"
+#include "base/strings/string_split.h"
+#include "net/base/net_pref_names.h"
+#include "net/http/http_auth_filter.h"
+#include "net/http/http_auth_preferences.h"
+#include "net/http/url_security_manager.h"
+
+namespace net {
+
+HttpAuthPreferences::HttpAuthPreferences()
+ : security_manager_(URLSecurityManager::Create()) {}
+
+HttpAuthPreferences::~HttpAuthPreferences() {}
+
+void HttpAuthPreferences::RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterStringPref(prefs::kAuthSchemes,
+ "basic,digest,ntlm,negotiate");
dgn 2015/11/13 18:24:17 for webview, we would need to have "basic,digest,n
+ registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false);
+ registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false);
+ registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string());
+ registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist,
+ std::string());
+ registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
+#if defined(OS_ANDROID)
+ registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType,
+ std::string());
+#endif
+}
+
+void HttpAuthPreferences::Init(
+ PrefService* local_state,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
+ auth_schemes_ =
+ base::SplitString(local_state->GetString(prefs::kAuthSchemes), ",",
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ negotiate_disable_cname_lookup_.Init(prefs::kDisableAuthNegotiateCnameLookup,
+ local_state);
+ negotiate_disable_cname_lookup_.MoveToThread(task_runner);
+ negotiate_enable_port_.Init(prefs::kEnableAuthNegotiatePort, local_state);
+ negotiate_enable_port_.MoveToThread(task_runner);
+ server_whitelist_.Init(prefs::kAuthServerWhitelist, local_state,
+ base::Bind(&HttpAuthPreferences::UpdateServerWhitelist,
+ base::Unretained(this)));
+ UpdateServerWhitelist();
+ server_whitelist_.MoveToThread(task_runner);
+ delegate_whitelist_.Init(
+ prefs::kAuthNegotiateDelegateWhitelist, local_state,
+ base::Bind(&HttpAuthPreferences::UpdateDelegateWhitelist,
+ base::Unretained(this)));
+ UpdateDelegateWhitelist();
+ delegate_whitelist_.MoveToThread(task_runner);
+#if defined(OS_ANDROID)
+ auth_android_negotiate_account_type_.Init(
+ prefs::kAuthAndroidNegotiateAccountType, local_state);
+ auth_android_negotiate_account_type_.MoveToThread(task_runner);
+#endif
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName);
+#endif
+}
+
+std::vector<std::string> HttpAuthPreferences::auth_schemes() const {
+ return auth_schemes_;
+}
+
+bool HttpAuthPreferences::negotiate_disable_cname_lookup() const {
+ return negotiate_disable_cname_lookup_.GetValue();
+}
+
+bool HttpAuthPreferences::negotiate_enable_port() const {
+ return negotiate_enable_port_.GetValue();
+}
+
+#if defined(OS_ANDROID)
+std::string HttpAuthPreferences::auth_android_negotiate_account_type() const {
+ return auth_android_negotiate_account_type_.GetValue();
+}
+#endif
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+std::string HttpAuthPreferences::gssapi_library_name() const {
+ return gssapi_library_name_;
+}
+#endif
+
+void HttpAuthPreferences::UpdateServerWhitelist() {
+ std::string server_whitelist = server_whitelist_.GetValue();
+ if (server_whitelist.empty()) {
+ security_manager_->SetDefaultWhitelist(scoped_ptr<HttpAuthFilter>());
+ } else {
+ security_manager_->SetDefaultWhitelist(scoped_ptr<HttpAuthFilter>(
+ new net::HttpAuthFilterWhitelist(server_whitelist)));
+ }
+}
+
+void HttpAuthPreferences::UpdateDelegateWhitelist() {
+ std::string delegate_whitelist = delegate_whitelist_.GetValue();
+ if (delegate_whitelist.empty()) {
+ security_manager_->SetDelegateWhitelist(scoped_ptr<HttpAuthFilter>());
+ } else {
+ security_manager_->SetDelegateWhitelist(scoped_ptr<HttpAuthFilter>(
+ new net::HttpAuthFilterWhitelist(delegate_whitelist)));
+ }
+}
+
+bool HttpAuthPreferences::CanUseDefaultCredentials(
+ const GURL& auth_origin) const {
+ return security_manager_->CanUseDefaultCredentials(auth_origin);
+}
+
+bool HttpAuthPreferences::CanDelegate(const GURL& auth_origin) const {
+ return security_manager_->CanDelegate(auth_origin);
+}
+
+} // namespace net
« no previous file with comments | « net/http/http_auth_preferences.h ('k') | net/http/http_auth_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698