blob: 83fc5e11ca08377287fa39606ff674b137d21675 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]d7f16632010-03-29 18:02:362// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_HTTP_URL_SECURITY_MANAGER_H_
6#define NET_HTTP_URL_SECURITY_MANAGER_H_
7
danakj1fd259a02016-04-16 03:17:098#include <memory>
9
Avi Drissman13fc8932015-12-20 04:40:4610#include "base/macros.h"
[email protected]172da1b2011-08-12 15:52:2611#include "net/base/net_export.h"
[email protected]b4955e7d2010-04-16 20:22:3012
[email protected]d7f16632010-03-29 18:02:3613class GURL;
14
15namespace net {
16
[email protected]930cbb52010-04-02 17:27:1017class HttpAuthFilter;
18
[email protected]d7f16632010-03-29 18:02:3619// The URL security manager controls the policies (allow, deny, prompt user)
20// regarding URL actions (e.g., sending the default credentials to a server).
aberentbba302d2015-12-03 10:20:1921class NET_EXPORT_PRIVATE URLSecurityManager {
[email protected]d7f16632010-03-29 18:02:3622 public:
[email protected]2227c692010-05-04 15:36:1123 URLSecurityManager() {}
24 virtual ~URLSecurityManager() {}
[email protected]d7f16632010-03-29 18:02:3625
26 // Creates a platform-dependent instance of URLSecurityManager.
[email protected]d201b200e2010-08-27 17:35:0227 //
Ryan Sleevia9d6aa62019-07-26 13:32:1828 // A security manager has two allowlists, a "default allowlist" that is a
29 // allowlist of servers with which default credentials can be used, and a
30 // "delegate allowlist" that is the allowlist of servers that are allowed to
aberentbba302d2015-12-03 10:20:1931 // have delegated Kerberos tickets.
32 //
Ryan Sleevia9d6aa62019-07-26 13:32:1833 // On creation both allowlists are empty.
aberentbba302d2015-12-03 10:20:1934 //
Ryan Sleevia9d6aa62019-07-26 13:32:1835 // If the default allowlist is empty and the platform is Windows, it indicates
[email protected]d201b200e2010-08-27 17:35:0236 // that security zone mapping should be used to determine whether default
Ryan Sleevia9d6aa62019-07-26 13:32:1837 // credentials should be used. If the default allowlist is empty and the
[email protected]d201b200e2010-08-27 17:35:0238 // platform is non-Windows, it indicates that no servers should be
Ryan Sleevia9d6aa62019-07-26 13:32:1839 // allowlisted.
[email protected]d201b200e2010-08-27 17:35:0240 //
Ryan Sleevia9d6aa62019-07-26 13:32:1841 // If the delegate allowlist is empty no servers can have delegated Kerberos
aberentbba302d2015-12-03 10:20:1942 // tickets.
[email protected]d201b200e2010-08-27 17:35:0243 //
Juan Jose Lopez Jaimez7fa1f002017-11-20 22:13:3344 static std::unique_ptr<URLSecurityManager> Create();
[email protected]d7f16632010-03-29 18:02:3645
46 // Returns true if we can send the default credentials to the server at
47 // |auth_origin| for HTTP NTLM or Negotiate authentication.
[email protected]d201b200e2010-08-27 17:35:0248 virtual bool CanUseDefaultCredentials(const GURL& auth_origin) const = 0;
49
50 // Returns true if Kerberos delegation is allowed for the server at
51 // |auth_origin| for HTTP Negotiate authentication.
52 virtual bool CanDelegate(const GURL& auth_origin) const = 0;
[email protected]930cbb52010-04-02 17:27:1053
Ryan Sleevia9d6aa62019-07-26 13:32:1854 virtual void SetDefaultAllowlist(
55 std::unique_ptr<HttpAuthFilter> allowlist_default) = 0;
56 virtual void SetDelegateAllowlist(
57 std::unique_ptr<HttpAuthFilter> allowlist_delegate) = 0;
aberentbba302d2015-12-03 10:20:1958
[email protected]b4955e7d2010-04-16 20:22:3059 private:
60 DISALLOW_COPY_AND_ASSIGN(URLSecurityManager);
61};
62
Ryan Sleevia9d6aa62019-07-26 13:32:1863class URLSecurityManagerAllowlist : public URLSecurityManager {
[email protected]b4955e7d2010-04-16 20:22:3064 public:
Ryan Sleevia9d6aa62019-07-26 13:32:1865 URLSecurityManagerAllowlist();
66 ~URLSecurityManagerAllowlist() override;
[email protected]b4955e7d2010-04-16 20:22:3067
68 // URLSecurityManager methods.
dchengb03027d2014-10-21 12:00:2069 bool CanUseDefaultCredentials(const GURL& auth_origin) const override;
70 bool CanDelegate(const GURL& auth_origin) const override;
Ryan Sleevia9d6aa62019-07-26 13:32:1871 void SetDefaultAllowlist(
72 std::unique_ptr<HttpAuthFilter> allowlist_default) override;
73 void SetDelegateAllowlist(
74 std::unique_ptr<HttpAuthFilter> allowlist_delegate) override;
aberentbba302d2015-12-03 10:20:1975
76 protected:
Ryan Sleevia9d6aa62019-07-26 13:32:1877 bool HasDefaultAllowlist() const;
[email protected]b4955e7d2010-04-16 20:22:3078
79 private:
Ryan Sleevia9d6aa62019-07-26 13:32:1880 std::unique_ptr<const HttpAuthFilter> allowlist_default_;
81 std::unique_ptr<const HttpAuthFilter> allowlist_delegate_;
[email protected]b4955e7d2010-04-16 20:22:3082
Ryan Sleevia9d6aa62019-07-26 13:32:1883 DISALLOW_COPY_AND_ASSIGN(URLSecurityManagerAllowlist);
[email protected]d7f16632010-03-29 18:02:3684};
85
[email protected]d7f16632010-03-29 18:02:3686} // namespace net
87
88#endif // NET_HTTP_URL_SECURITY_MANAGER_H_