Skip to content

Commit c69f2f8

Browse files
committed
Merge branch 'cs/http-use-basic-after-failed-negotiate'
Regression fix for a change made during this cycle. * cs/http-use-basic-after-failed-negotiate: Revert "remote-curl: fall back to basic auth if Negotiate fails" t5551: test http interaction with credential helpers
2 parents 88dd428 + ecf7b12 commit c69f2f8

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

Documentation/RelNotes/2.32.0.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ UI, Workflows & Features
4747
tweak both the message and the contents, and only the message,
4848
respectively.
4949

50-
* When accessing a server with a URL like https://user:pass@site/, we
51-
did not to fall back to the basic authentication with the
52-
credential material embedded in the URL after the "Negotiate"
53-
authentication failed. Now we do.
54-
5550
* "git send-email" learned to honor the core.hooksPath configuration.
5651

5752
* "git format-patch -v<n>" learned to allow a reroll count that is

http.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,18 +1650,17 @@ static int handle_curl_result(struct slot_results *results)
16501650
} else if (missing_target(results))
16511651
return HTTP_MISSING_TARGET;
16521652
else if (results->http_code == 401) {
1653-
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1654-
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
1655-
if (results->auth_avail) {
1656-
http_auth_methods &= results->auth_avail;
1657-
http_auth_methods_restricted = 1;
1658-
return HTTP_REAUTH;
1659-
}
1660-
#endif
16611653
if (http_auth.username && http_auth.password) {
16621654
credential_reject(&http_auth);
16631655
return HTTP_NOAUTH;
16641656
} else {
1657+
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1658+
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
1659+
if (results->auth_avail) {
1660+
http_auth_methods &= results->auth_avail;
1661+
http_auth_methods_restricted = 1;
1662+
}
1663+
#endif
16651664
return HTTP_REAUTH;
16661665
}
16671666
} else {

t/t5551-http-fetch-smart.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,4 +517,45 @@ test_expect_success 'server-side error detected' '
517517
test_i18ngrep "server-side error" actual
518518
'
519519

520+
test_expect_success 'http auth remembers successful credentials' '
521+
rm -f .git-credentials &&
522+
test_config credential.helper store &&
523+
524+
# the first request prompts the user...
525+
set_askpass user@host pass@host &&
526+
git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
527+
expect_askpass both user@host &&
528+
529+
# ...and the second one uses the stored value rather than
530+
# prompting the user.
531+
set_askpass bogus-user bogus-pass &&
532+
git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
533+
expect_askpass none
534+
'
535+
536+
test_expect_success 'http auth forgets bogus credentials' '
537+
# seed credential store with bogus values. In real life,
538+
# this would probably come from a password which worked
539+
# for a previous request.
540+
rm -f .git-credentials &&
541+
test_config credential.helper store &&
542+
{
543+
echo "url=$HTTPD_URL" &&
544+
echo "username=bogus" &&
545+
echo "password=bogus"
546+
} | git credential approve &&
547+
548+
# we expect this to use the bogus values and fail, never even
549+
# prompting the user...
550+
set_askpass user@host pass@host &&
551+
test_must_fail git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
552+
expect_askpass none &&
553+
554+
# ...but now we should have forgotten the bad value, causing
555+
# us to prompt the user again.
556+
set_askpass user@host pass@host &&
557+
git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
558+
expect_askpass both user@host
559+
'
560+
520561
test_done

0 commit comments

Comments
 (0)