Skip to content

Commit 9fa7afe

Browse files
mjcheethamGit for Windows Build Agent
authored andcommitted
http: fix bug in ntlm_allow=1 handling
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. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 65a6ef1 commit 9fa7afe

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

http.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,10 +1932,6 @@ static int handle_curl_result(struct slot_results *results)
19321932
else if (results->http_code == 401) {
19331933
http_auth.ntlm_suppressed = (results->auth_avail & CURLAUTH_NTLM) &&
19341934
!(http_auth_any & CURLAUTH_NTLM);
1935-
if (http_auth.ntlm_suppressed && http_auth.ntlm_allow) {
1936-
http_auth_methods |= CURLAUTH_NTLM;
1937-
return HTTP_REAUTH;
1938-
}
19391935
if ((http_auth.username && http_auth.password) ||\
19401936
(http_auth.authtype && http_auth.credential)) {
19411937
if (http_auth.multistage) {
@@ -2468,6 +2464,13 @@ static int http_request_recoverable(const char *url,
24682464
credential_fill(the_repository, &http_auth, 1);
24692465
}
24702466

2467+
/*
2468+
* Re-enable NTLM auth if the helper allows it and we would
2469+
* otherwise suppress authentication via NTLM.
2470+
*/
2471+
if (http_auth.ntlm_suppressed && http_auth.ntlm_allow)
2472+
http_auth_methods |= CURLAUTH_NTLM;
2473+
24712474
ret = http_request(url, result, target, options);
24722475
}
24732476
if (ret == HTTP_RATE_LIMITED) {

0 commit comments

Comments
 (0)