Skip to content

Commit a942fa7

Browse files
committed
http: warn if might have failed because of NTLM
The new default of Git is to disable NTLM authentication by default. To help users find the escape hatch of that config setting, should they need it, suggest it when the authentication failed and the server had offered NTLM, i.e. if re-enabling it would fix the problem. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 4d5ffd2 commit a942fa7

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

http.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,17 @@ static int handle_curl_result(struct slot_results *results)
19151915
credential_reject(&http_auth);
19161916
if (always_auth_proactively())
19171917
http_proactive_auth = PROACTIVE_AUTH_NONE;
1918+
if ((results->auth_avail & CURLAUTH_NTLM) &&
1919+
!(http_auth_any & CURLAUTH_NTLM)) {
1920+
warning(_("Due to its cryptographic weaknesses, "
1921+
"NTLM authentication has been\n"
1922+
"disabled in Git by default. You can "
1923+
"re-enable it for trusted servers\n"
1924+
"by running:\n\n"
1925+
"git config set "
1926+
"http.%s://%s.allowNTLMAuth true"),
1927+
http_auth.protocol, http_auth.host);
1928+
}
19181929
return HTTP_NOAUTH;
19191930
} else {
19201931
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;

t/t5563-simple-http-auth.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ test_expect_success NTLM 'access using NTLM auth' '
687687
688688
test_config_global credential.helper test-helper &&
689689
test_must_fail env GIT_TRACE_CURL=1 git \
690-
ls-remote "$HTTPD_URL/ntlm_auth/repo.git" &&
690+
ls-remote "$HTTPD_URL/ntlm_auth/repo.git" 2>err &&
691+
test_grep "allowNTLMAuth" err &&
691692
GIT_TRACE_CURL=1 git -c http.$HTTPD_URL.allowNTLMAuth=true \
692693
ls-remote "$HTTPD_URL/ntlm_auth/repo.git"
693694
'

0 commit comments

Comments
 (0)