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

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

Issue 10916272: Remove HttpAuth::Scheme enum in favor of a string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_auth.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_H_
6 #define NET_HTTP_HTTP_AUTH_H_ 6 #define NET_HTTP_HTTP_AUTH_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // The identity was provided by RestartWithAuth -- it likely 81 // The identity was provided by RestartWithAuth -- it likely
82 // came from a prompt (or maybe the password manager). 82 // came from a prompt (or maybe the password manager).
83 IDENT_SRC_EXTERNAL, 83 IDENT_SRC_EXTERNAL,
84 84
85 // The identity used the default credentials for the computer, 85 // The identity used the default credentials for the computer,
86 // on schemes that support single sign-on. 86 // on schemes that support single sign-on.
87 IDENT_SRC_DEFAULT_CREDENTIALS, 87 IDENT_SRC_DEFAULT_CREDENTIALS,
88 }; 88 };
89 89
90 enum Scheme {
91 AUTH_SCHEME_BASIC = 0,
92 AUTH_SCHEME_DIGEST,
93 AUTH_SCHEME_NTLM,
94 AUTH_SCHEME_NEGOTIATE,
95 AUTH_SCHEME_MOCK,
96 AUTH_SCHEME_MAX,
97 };
98
99 // Helper structure used by HttpNetworkTransaction to track 90 // Helper structure used by HttpNetworkTransaction to track
100 // the current identity being used for authorization. 91 // the current identity being used for authorization.
101 struct Identity { 92 struct Identity {
102 Identity(); 93 Identity();
103 94
104 IdentitySource source; 95 IdentitySource source;
105 bool invalid; 96 bool invalid;
106 AuthCredentials credentials; 97 AuthCredentials credentials;
107 }; 98 };
108 99
109 // Get the name of the header containing the auth challenge 100 // Get the name of the header containing the auth challenge
110 // (either WWW-Authenticate or Proxy-Authenticate). 101 // (either WWW-Authenticate or Proxy-Authenticate).
111 static std::string GetChallengeHeaderName(Target target); 102 static std::string GetChallengeHeaderName(Target target);
112 103
113 // Get the name of the header where the credentials go 104 // Get the name of the header where the credentials go
114 // (either Authorization or Proxy-Authorization). 105 // (either Authorization or Proxy-Authorization).
115 static std::string GetAuthorizationHeaderName(Target target); 106 static std::string GetAuthorizationHeaderName(Target target);
116 107
117 // Returns a string representation of a Target value that can be used in log 108 // Returns a string representation of a Target value that can be used in log
118 // messages. 109 // messages.
119 static std::string GetAuthTargetString(Target target); 110 static std::string GetAuthTargetString(Target target);
120 111
121 // Returns a string representation of an authentication Scheme.
122 static const char* SchemeToString(Scheme scheme);
123
124 // Iterate through the challenge headers, and pick the best one that 112 // Iterate through the challenge headers, and pick the best one that
125 // we support. Obtains the implementation class for handling the challenge, 113 // we support. Obtains the implementation class for handling the challenge,
126 // and passes it back in |*handler|. If no supported challenge was found, 114 // and passes it back in |*handler|. If no supported challenge was found,
127 // |*handler| is set to NULL. 115 // |*handler| is set to NULL.
128 // 116 //
129 // |disabled_schemes| is the set of schemes that we should not use. 117 // |disabled_schemes| is the set of schemes that we should not use.
130 // 118 //
131 // |origin| is used by the NTLM and Negotiation authentication scheme to 119 // |origin| is used by the NTLM and Negotiation authentication scheme to
132 // construct the service principal name. It is ignored by other schemes. 120 // construct the service principal name. It is ignored by other schemes.
133 static void ChooseBestChallenge( 121 static void ChooseBestChallenge(
134 HttpAuthHandlerFactory* http_auth_handler_factory, 122 HttpAuthHandlerFactory* http_auth_handler_factory,
135 const HttpResponseHeaders* headers, 123 const HttpResponseHeaders* headers,
136 Target target, 124 Target target,
137 const GURL& origin, 125 const GURL& origin,
138 const std::set<Scheme>& disabled_schemes, 126 const std::set<std::string>& disabled_schemes,
139 const BoundNetLog& net_log, 127 const BoundNetLog& net_log,
140 scoped_ptr<HttpAuthHandler>* handler); 128 scoped_ptr<HttpAuthHandler>* handler);
141 129
142 // Handle a 401/407 response from a server/proxy after a previous 130 // Handle a 401/407 response from a server/proxy after a previous
143 // authentication attempt. For connection-based authentication schemes, the 131 // authentication attempt. For connection-based authentication schemes, the
144 // new response may be another round in a multi-round authentication sequence. 132 // new response may be another round in a multi-round authentication sequence.
145 // For request-based schemes, a 401/407 response is typically treated like a 133 // For request-based schemes, a 401/407 response is typically treated like a
146 // rejection of the previous challenge, except in the Digest case when a 134 // rejection of the previous challenge, except in the Digest case when a
147 // "stale" attribute is present. 135 // "stale" attribute is present.
148 // 136 //
149 // |handler| must be non-NULL, and is the HttpAuthHandler from the previous 137 // |handler| must be non-NULL, and is the HttpAuthHandler from the previous
150 // authentication round. 138 // authentication round.
151 // 139 //
152 // |headers| must be non-NULL and contain the new HTTP response. 140 // |headers| must be non-NULL and contain the new HTTP response.
153 // 141 //
154 // |target| specifies whether the authentication challenge response came 142 // |target| specifies whether the authentication challenge response came
155 // from a server or a proxy. 143 // from a server or a proxy.
156 // 144 //
157 // |disabled_schemes| are the authentication schemes to ignore. 145 // |disabled_schemes| are the authentication schemes to ignore.
158 // 146 //
159 // |challenge_used| is the text of the authentication challenge used in 147 // |challenge_used| is the text of the authentication challenge used in
160 // support of the returned AuthorizationResult. If no headers were used for 148 // support of the returned AuthorizationResult. If no headers were used for
161 // the result (for example, all headers have unknown authentication schemes), 149 // the result (for example, all headers have unknown authentication schemes),
162 // the value is cleared. 150 // the value is cleared.
163 static AuthorizationResult HandleChallengeResponse( 151 static AuthorizationResult HandleChallengeResponse(
164 HttpAuthHandler* handler, 152 HttpAuthHandler* handler,
165 const HttpResponseHeaders* headers, 153 const HttpResponseHeaders* headers,
166 Target target, 154 Target target,
167 const std::set<Scheme>& disabled_schemes, 155 const std::set<std::string>& disabled_schemes,
168 std::string* challenge_used); 156 std::string* challenge_used);
169 157
170 // Breaks up a challenge string into the the auth scheme and parameter list, 158 // Breaks up a challenge string into the the auth scheme and parameter list,
171 // according to RFC 2617 Sec 1.2: 159 // according to RFC 2617 Sec 1.2:
172 // challenge = auth-scheme 1*SP 1#auth-param 160 // challenge = auth-scheme 1*SP 1#auth-param
173 // 161 //
174 // Depending on the challenge scheme, it may be appropriate to interpret the 162 // Depending on the challenge scheme, it may be appropriate to interpret the
175 // parameters as either a base-64 encoded string or a comma-delimited list 163 // parameters as either a base-64 encoded string or a comma-delimited list
176 // of name-value pairs. param_pairs() and base64_param() methods are provided 164 // of name-value pairs. param_pairs() and base64_param() methods are provided
177 // to support either usage. 165 // to support either usage.
(...skipping 28 matching lines...) Expand all
206 std::string::const_iterator scheme_end_; 194 std::string::const_iterator scheme_end_;
207 195
208 std::string::const_iterator params_begin_; 196 std::string::const_iterator params_begin_;
209 std::string::const_iterator params_end_; 197 std::string::const_iterator params_end_;
210 }; 198 };
211 }; 199 };
212 200
213 } // namespace net 201 } // namespace net
214 202
215 #endif // NET_HTTP_HTTP_AUTH_H_ 203 #endif // NET_HTTP_HTTP_AUTH_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698