Skip to content

Commit 1b0d954

Browse files
chschenkgitster
authored andcommitted
remote-curl: fall back to basic auth if Negotiate fails
When the username and password are supplied in a url like this https://myuser:[email protected]/myrepo.git and the server supports the negotiate authenticaten method, git does not fall back to basic auth and libcurl hardly tries to authenticate with the negotiate method. Stop using the Negotiate authentication method after the first failure because if it fails on the first try it will never succeed. Signed-off-by: Christopher Schenk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98164e9 commit 1b0d954

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

http.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,17 +1641,18 @@ 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
16441652
if (http_auth.username && http_auth.password) {
16451653
credential_reject(&http_auth);
16461654
return HTTP_NOAUTH;
16471655
} 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
16551656
return HTTP_REAUTH;
16561657
}
16571658
} else {

0 commit comments

Comments
 (0)