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

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

Issue 6525035: Invalidate credentials if the server rejects them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify auth handlers for basic and digest Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "net/http/http_auth.h" 5 #include "net/http/http_auth.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Save the scheme's position. 119 // Save the scheme's position.
120 scheme_begin_ = tok.token_begin(); 120 scheme_begin_ = tok.token_begin();
121 scheme_end_ = tok.token_end(); 121 scheme_end_ = tok.token_end();
122 122
123 params_begin_ = scheme_end_; 123 params_begin_ = scheme_end_;
124 params_end_ = end; 124 params_end_ = end;
125 HttpUtil::TrimLWS(&params_begin_, &params_end_); 125 HttpUtil::TrimLWS(&params_begin_, &params_end_);
126 } 126 }
127 127
128 // static 128 // static
129 bool HttpAuth::ShouldInvalidateRejectedAuth(
130 const HttpResponseHeaders* headers,
131 Target target,
132 HttpAuthHandler* handler) {
133 const std::string header_name = GetChallengeHeaderName(target);
134 std::string cur_challenge;
135 std::string cur_scheme_name = SchemeToString(handler->auth_scheme());
136 void* iter = NULL;
137
138 while (headers->EnumerateHeader(&iter, header_name, &cur_challenge)) {
139 ChallengeTokenizer props(cur_challenge.begin(), cur_challenge.end());
140
141 if (LowerCaseEqualsASCII(props.scheme(), cur_scheme_name.c_str()) &&
142 handler->ShouldInvalidateRejectedAuth(&props))
143 return true;
144 }
145 return false;
146 }
147
148 // static
129 std::string HttpAuth::GetChallengeHeaderName(Target target) { 149 std::string HttpAuth::GetChallengeHeaderName(Target target) {
130 switch (target) { 150 switch (target) {
131 case AUTH_PROXY: 151 case AUTH_PROXY:
132 return "Proxy-Authenticate"; 152 return "Proxy-Authenticate";
133 case AUTH_SERVER: 153 case AUTH_SERVER:
134 return "WWW-Authenticate"; 154 return "WWW-Authenticate";
135 default: 155 default:
136 NOTREACHED(); 156 NOTREACHED();
137 return ""; 157 return "";
138 } 158 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX, 196 COMPILE_ASSERT(arraysize(kSchemeNames) == AUTH_SCHEME_MAX,
177 http_auth_scheme_names_incorrect_size); 197 http_auth_scheme_names_incorrect_size);
178 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) { 198 if (scheme < AUTH_SCHEME_BASIC || scheme >= AUTH_SCHEME_MAX) {
179 NOTREACHED(); 199 NOTREACHED();
180 return "invalid_scheme"; 200 return "invalid_scheme";
181 } 201 }
182 return kSchemeNames[scheme]; 202 return kSchemeNames[scheme];
183 } 203 }
184 204
185 } // namespace net 205 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698