Skip to content

Commit ecf7b12

Browse files
peffgitster
authored andcommitted
Revert "remote-curl: fall back to basic auth if Negotiate fails"
This reverts commit 1b0d954. That commit does fix the situation it intended to (avoiding Negotiate even when the credentials were provided in the URL), but it creates a more serious regression: we now never hit the conditional for "we had a username and password, tried them, but the server still gave us a 401". That has two bad effects: 1. we never call credential_reject(), and thus a bogus credential stored by a helper will live on forever 2. we never return HTTP_NOAUTH, so the error message the user gets is "The requested URL returned error: 401", instead of "Authentication failed". Doing this correctly seems non-trivial, as we don't know whether the Negotiate auth was a problem. Since this is a regression in the upcoming v2.23.0 release (for which we're in -rc0), let's revert for now and work on a fix separately. (Note that this isn't a pure revert; the previous commit added a test showing the regression, so we can now flip it to expect_success). Reported-by: Ben Humphreys <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b694f1e commit ecf7b12

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

http.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,18 +1641,17 @@ static int handle_curl_result(struct slot_results *results)
16411641
} else if (missing_target(results))
16421642
return HTTP_MISSING_TARGET;
16431643
else if (results->http_code == 401) {
1644-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1645-
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
1646-
if (results->auth_avail) {
1647-
http_auth_methods &= results->auth_avail;
1648-
http_auth_methods_restricted = 1;
1649-
return HTTP_REAUTH;
1650-
}
1651-
#endif
16521644
if (http_auth.username && http_auth.password) {
16531645
credential_reject(&http_auth);
16541646
return HTTP_NOAUTH;
16551647
} else {
1648+
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1649+
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
1650+
if (results->auth_avail) {
1651+
http_auth_methods &= results->auth_avail;
1652+
http_auth_methods_restricted = 1;
1653+
}
1654+
#endif
16561655
return HTTP_REAUTH;
16571656
}
16581657
} else {

t/t5551-http-fetch-smart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ test_expect_success 'http auth remembers successful credentials' '
533533
expect_askpass none
534534
'
535535

536-
test_expect_failure 'http auth forgets bogus credentials' '
536+
test_expect_success 'http auth forgets bogus credentials' '
537537
# seed credential store with bogus values. In real life,
538538
# this would probably come from a password which worked
539539
# for a previous request.

0 commit comments

Comments
 (0)