remote-curl: fall back to basic auth if Negotiate fails
When the username and password are supplied in a url like this https://myuser:secret@git.exampe/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 <christopher@cschenk.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christopher Schenk committed
Mar 22, 2021 at 11:51 UTC
1b0d9545bb85912a16b367229d414f55d140d3be
1 file changed
+8
-7
http.c
+8
-7
@@ -1641,17 +1641,18 @@ static int handle_curl_result(struct slot_results *results)
1641
} else if (missing_target(results))
1642
return HTTP_MISSING_TARGET;
1643
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
1652
if (http_auth.username && http_auth.password) {
1653
credential_reject(&http_auth);
1654
return HTTP_NOAUTH;
1655
} 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
1656
return HTTP_REAUTH;
1657
}
1658
} else {