Skip to content

Commit 1751905

Browse files
authored
http: fix bug in ntlm_allow=1 handling (#6136)
In 816db62 (credential: advertise NTLM suppression and allow helpers to re-enable, 2026-02-09), Git learned to advertise that NTLM authentication was suppressed to credential helpers. It also introduced a way to allow credential helpers to opt-back-in to NTLM authentication via the `ntlm_allow=1` credential protocol flag. There is a bug in the logic of 816db62 that means we are responding to the `ntlm_allow=1` signal too late in the auth retry codepath; we've already made the second-attempt request! Move adding of NTLM as a valid auth method to `http_request_reauth` right after the credential helper is consulted following the first request, but (now) before we made the second request.
2 parents e9edee0 + 8c8b1c8 commit 1751905

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

http.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,10 +1908,6 @@ static int handle_curl_result(struct slot_results *results)
19081908
else if (results->http_code == 401) {
19091909
http_auth.ntlm_suppressed = (results->auth_avail & CURLAUTH_NTLM) &&
19101910
!(http_auth_any & CURLAUTH_NTLM);
1911-
if (http_auth.ntlm_suppressed && http_auth.ntlm_allow) {
1912-
http_auth_methods |= CURLAUTH_NTLM;
1913-
return HTTP_REAUTH;
1914-
}
19151911
if ((http_auth.username && http_auth.password) ||\
19161912
(http_auth.authtype && http_auth.credential)) {
19171913
if (http_auth.multistage) {
@@ -2373,6 +2369,13 @@ static int http_request_reauth(const char *url,
23732369

23742370
credential_fill(the_repository, &http_auth, 1);
23752371

2372+
/*
2373+
* Re-enable NTLM auth if the helper allows it and we would
2374+
* otherwise suppress authentication via NTLM.
2375+
*/
2376+
if (http_auth.ntlm_suppressed && http_auth.ntlm_allow)
2377+
http_auth_methods |= CURLAUTH_NTLM;
2378+
23762379
ret = http_request(url, result, target, options);
23772380
}
23782381
return ret;

0 commit comments

Comments
 (0)