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

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

Issue 6525035: Invalidate credentials if the server rejects them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Defer browser tests to another CL 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_handler_digest.h" 5 #include "net/http/http_auth_handler_digest.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 HttpAuth::AuthorizationResult HttpAuthHandlerDigest::HandleAnotherChallenge( 107 HttpAuth::AuthorizationResult HttpAuthHandlerDigest::HandleAnotherChallenge(
108 HttpAuth::ChallengeTokenizer* challenge) { 108 HttpAuth::ChallengeTokenizer* challenge) {
109 // Even though Digest is not connection based, a "second round" is parsed 109 // Even though Digest is not connection based, a "second round" is parsed
110 // to differentiate between stale and rejected responses. 110 // to differentiate between stale and rejected responses.
111 // Note that the state of the current handler is not mutated - this way if 111 // Note that the state of the current handler is not mutated - this way if
112 // there is a rejection the realm hasn't changed. 112 // there is a rejection the realm hasn't changed.
113 if (!LowerCaseEqualsASCII(challenge->scheme(), "digest")) 113 if (!LowerCaseEqualsASCII(challenge->scheme(), "digest"))
114 return HttpAuth::AUTHORIZATION_RESULT_INVALID; 114 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
115 115
116 HttpUtil::NameValuePairsIterator parameters = challenge->param_pairs(); 116 HttpUtil::NameValuePairsIterator parameters = challenge->param_pairs();
117 std::string realm;
117 118
118 // Try to find the "stale" value. 119 // Try to find the "stale" value, and also keep track of the realm
120 // for the new challenge.
119 while (parameters.GetNext()) { 121 while (parameters.GetNext()) {
120 if (!LowerCaseEqualsASCII(parameters.name(), "stale")) 122 if (LowerCaseEqualsASCII(parameters.name(), "stale")) {
121 continue; 123 if (LowerCaseEqualsASCII(parameters.value(), "true"))
122 if (LowerCaseEqualsASCII(parameters.value(), "true")) 124 return HttpAuth::AUTHORIZATION_RESULT_STALE;
wtc 2011/02/22 23:17:32 IMPORTANT: what if the new challenge has both stal
cbentzel 2011/02/23 14:49:54 It could happen, but it seems unexpected. It seems
asanka 2011/02/23 18:06:40 RFC 2617 states that the 'stale' value should only
123 return HttpAuth::AUTHORIZATION_RESULT_STALE; 125 } else if (LowerCaseEqualsASCII(parameters.name(), "realm")) {
126 realm = parameters.value();
127 }
124 } 128 }
125 129 return (realm_ != realm) ?
126 return HttpAuth::AUTHORIZATION_RESULT_REJECT; 130 HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM :
131 HttpAuth::AUTHORIZATION_RESULT_REJECT;
127 } 132 }
128 133
129 bool HttpAuthHandlerDigest::Init(HttpAuth::ChallengeTokenizer* challenge) { 134 bool HttpAuthHandlerDigest::Init(HttpAuth::ChallengeTokenizer* challenge) {
130 return ParseChallenge(challenge); 135 return ParseChallenge(challenge);
131 } 136 }
132 137
133 int HttpAuthHandlerDigest::GenerateAuthTokenImpl( 138 int HttpAuthHandlerDigest::GenerateAuthTokenImpl(
134 const string16* username, 139 const string16* username,
135 const string16* password, 140 const string16* password,
136 const HttpRequestInfo* request, 141 const HttpRequestInfo* request,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // TODO(eroman): Supposedly IIS server requires quotes surrounding qop. 371 // TODO(eroman): Supposedly IIS server requires quotes surrounding qop.
367 authorization += ", qop=" + QopToString(qop_); 372 authorization += ", qop=" + QopToString(qop_);
368 authorization += ", nc=" + nc; 373 authorization += ", nc=" + nc;
369 authorization += ", cnonce=" + HttpUtil::Quote(cnonce); 374 authorization += ", cnonce=" + HttpUtil::Quote(cnonce);
370 } 375 }
371 376
372 return authorization; 377 return authorization;
373 } 378 }
374 379
375 } // namespace net 380 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698