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

Unified Diff: net/http/http_auth_controller.cc

Issue 2432873003: [Merge-54][net/auth] Don't abort network transaction over non-permanent auth errors. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_auth_controller.h ('k') | net/http/http_auth_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_controller.cc
diff --git a/net/http/http_auth_controller.cc b/net/http/http_auth_controller.cc
index d5c0c891da68ec28009de5d3b620a97261af1c4a..7ad290e448bedadda9f24fdf129c9f9f781c1764 100644
--- a/net/http/http_auth_controller.cc
+++ b/net/http/http_auth_controller.cc
@@ -157,13 +157,13 @@ int HttpAuthController::MaybeGenerateAuthToken(
credentials, request,
base::Bind(&HttpAuthController::OnIOComplete, base::Unretained(this)),
&auth_token_);
- if (DisableOnAuthHandlerResult(rv))
- rv = OK;
- if (rv == ERR_IO_PENDING)
+
+ if (rv == ERR_IO_PENDING) {
callback_ = callback;
- else
- OnIOComplete(rv);
- return rv;
+ return rv;
+ }
+
+ return HandleGenerateTokenResult(rv);
}
bool HttpAuthController::SelectPreemptiveAuth(const BoundNetLog& net_log) {
@@ -470,10 +470,21 @@ void HttpAuthController::PopulateAuthChallenge() {
auth_info_->realm = handler_->realm();
}
-bool HttpAuthController::DisableOnAuthHandlerResult(int result) {
+int HttpAuthController::HandleGenerateTokenResult(int result) {
DCHECK(CalledOnValidThread());
-
switch (result) {
+ case ERR_INVALID_AUTH_CREDENTIALS:
+ // If the GenerateAuthToken call fails with this error, this means that
+ // the handler can no longer be used. However, the authentication scheme
+ // is considered still usable. This allows a scheme that attempted and
+ // failed to use default credentials to recover and use explicit
+ // credentials.
+ //
+ // If the handler does not support any remaining identity sources, then
+ // the authentication controller will pick another authentication handler.
+ auth_token_.clear();
+ return OK;
+
// Occurs with GSSAPI, if the user has not already logged in.
case ERR_MISSING_AUTH_CREDENTIALS:
@@ -493,17 +504,16 @@ bool HttpAuthController::DisableOnAuthHandlerResult(int result) {
// succeed.
DisableAuthScheme(handler_->auth_scheme());
auth_token_.clear();
- return true;
+ return OK;
default:
- return false;
+ return result;
}
}
void HttpAuthController::OnIOComplete(int result) {
DCHECK(CalledOnValidThread());
- if (DisableOnAuthHandlerResult(result))
- result = OK;
+ result = HandleGenerateTokenResult(result);
if (!callback_.is_null()) {
CompletionCallback c = callback_;
callback_.Reset();
« no previous file with comments | « net/http/http_auth_controller.h ('k') | net/http/http_auth_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698