Skip to content

Commit b24f377

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 a495d10 commit b24f377

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
@@ -1874,6 +1874,17 @@ static int handle_curl_result(struct slot_results *results)
18741874
credential_reject(the_repository, &http_auth);
18751875
if (always_auth_proactively())
18761876
http_proactive_auth = PROACTIVE_AUTH_NONE;
1877+
if ((results->auth_avail & CURLAUTH_NTLM) &&
1878+
!(http_auth_any & CURLAUTH_NTLM)) {
1879+
warning(_("Due to its cryptographic weaknesses, "
1880+
"NTLM authentication has been\n"
1881+
"disabled in Git by default. You can "
1882+
"re-enable it for trusted servers\n"
1883+
"by running:\n\n"
1884+
"git config set "
1885+
"http.%s://%s.allowNTLMAuth true"),
1886+
http_auth.protocol, http_auth.host);
1887+
}
18771888
return HTTP_NOAUTH;
18781889
} else {
18791890
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
@@ -686,7 +686,8 @@ test_expect_success NTLM 'access using NTLM auth' '
686686
687687
test_config_global credential.helper test-helper &&
688688
test_must_fail env GIT_TRACE_CURL=1 git \
689-
ls-remote "$HTTPD_URL/ntlm_auth/repo.git" &&
689+
ls-remote "$HTTPD_URL/ntlm_auth/repo.git" 2>err &&
690+
test_grep "allowNTLMAuth" err &&
690691
GIT_TRACE_CURL=1 git -c http.$HTTPD_URL.allowNTLMAuth=true \
691692
ls-remote "$HTTPD_URL/ntlm_auth/repo.git"
692693
'

0 commit comments

Comments
 (0)