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

Side by Side Diff: net/http/http_auth_filter.h

Issue 1151843002: DO NOT LAND Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More. Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_AUTH_FILTER_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_FILTER_H_
6 #define NET_HTTP_HTTP_AUTH_FILTER_H_ 6 #define NET_HTTP_HTTP_AUTH_FILTER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/http/http_auth.h" 12 #include "net/http/http_auth.h"
13 #include "net/proxy/proxy_bypass_rules.h" 13 #include "net/proxy/proxy_bypass_rules.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace net { 17 namespace net {
18 18
19 // |HttpAuthFilter|s determine whether an authentication scheme should be 19 // |HttpAuthFilter|s determine whether an authentication scheme should be
20 // allowed for a particular peer. 20 // allowed for a particular peer.
21 class NET_EXPORT_PRIVATE HttpAuthFilter { 21 class NET_EXPORT_PRIVATE HttpAuthFilter {
22 public: 22 public:
23 virtual ~HttpAuthFilter() {} 23 virtual ~HttpAuthFilter() {}
24 24
25 // Checks if (|url|, |target|) is supported by the authentication scheme. 25 // Checks if (|origin|, |target|) is supported by the authentication scheme.
26 // Only the host of |url| is examined. 26 // Only the host of |origin| is examined.
27 virtual bool IsValid(const GURL& url, HttpAuth::Target target) const = 0; 27 virtual bool IsValid(const url::Origin& origin,
28 HttpAuth::Target target) const = 0;
28 }; 29 };
29 30
30 // Whitelist HTTP authentication filter. 31 // Whitelist HTTP authentication filter.
31 // Explicit whitelists of domains are set via SetWhitelist(). 32 // Explicit whitelists of domains are set via SetWhitelist().
32 // 33 //
33 // Uses the ProxyBypassRules class to do whitelisting for servers. 34 // Uses the ProxyBypassRules class to do whitelisting for servers.
34 // All proxies are allowed. 35 // All proxies are allowed.
35 class NET_EXPORT HttpAuthFilterWhitelist : public HttpAuthFilter { 36 class NET_EXPORT HttpAuthFilterWhitelist : public HttpAuthFilter {
36 public: 37 public:
37 explicit HttpAuthFilterWhitelist(const std::string& server_whitelist); 38 explicit HttpAuthFilterWhitelist(const std::string& server_whitelist);
38 ~HttpAuthFilterWhitelist() override; 39 ~HttpAuthFilterWhitelist() override;
39 40
40 // Adds an individual URL |filter| to the list, of the specified |target|. 41 // Adds an individual URL |filter| to the list, of the specified |target|.
41 bool AddFilter(const std::string& filter, HttpAuth::Target target); 42 bool AddFilter(const std::string& filter, HttpAuth::Target target);
42 43
43 // Adds a rule that bypasses all "local" hostnames. 44 // Adds a rule that bypasses all "local" hostnames.
44 void AddRuleToBypassLocal(); 45 void AddRuleToBypassLocal();
45 46
46 const ProxyBypassRules& rules() const { return rules_; } 47 const ProxyBypassRules& rules() const { return rules_; }
47 48
48 // HttpAuthFilter methods: 49 // HttpAuthFilter methods:
49 bool IsValid(const GURL& url, HttpAuth::Target target) const override; 50 bool IsValid(const url::Origin& origin,
51 HttpAuth::Target target) const override;
50 52
51 private: 53 private:
52 // Installs the whitelist. 54 // Installs the whitelist.
53 // |server_whitelist| is parsed by ProxyBypassRules. 55 // |server_whitelist| is parsed by ProxyBypassRules.
54 void SetWhitelist(const std::string& server_whitelist); 56 void SetWhitelist(const std::string& server_whitelist);
55 57
56 // We are using ProxyBypassRules because they have the functionality that we 58 // We are using ProxyBypassRules because they have the functionality that we
57 // want, but we are not using it for proxy bypass. 59 // want, but we are not using it for proxy bypass.
58 ProxyBypassRules rules_; 60 ProxyBypassRules rules_;
59 61
60 DISALLOW_COPY_AND_ASSIGN(HttpAuthFilterWhitelist); 62 DISALLOW_COPY_AND_ASSIGN(HttpAuthFilterWhitelist);
61 }; 63 };
62 64
63 } // namespace net 65 } // namespace net
64 66
65 #endif // NET_HTTP_HTTP_AUTH_FILTER_H_ 67 #endif // NET_HTTP_HTTP_AUTH_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698