Skip to content

Commit 8f3d03d

Browse files
committed
Merge branch 'bc/http-fallback-to-password-after-krb-fails' into maint
After attempting and failing a password-less authentication (e.g. kerberos), libcURL refuses to fall back to password based Basic authentication without a bit of help/encouragement. * bc/http-fallback-to-password-after-krb-fails: remote-curl: fall back to Basic auth if Negotiate fails
2 parents 6606129 + 4dbe664 commit 8f3d03d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ static const char *user_agent;
6262

6363
static struct credential cert_auth = CREDENTIAL_INIT;
6464
static int ssl_cert_password_required;
65+
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
66+
static unsigned long http_auth_methods = CURLAUTH_ANY;
67+
#endif
6568

6669
static struct curl_slist *pragma_header;
6770
static struct curl_slist *no_pragma_header;
@@ -580,6 +583,9 @@ struct active_request_slot *get_active_slot(void)
580583
curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
581584
curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
582585
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 1);
586+
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
587+
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
588+
#endif
583589
if (http_auth.password)
584590
init_curl_http_auth(slot->curl);
585591

@@ -870,6 +876,9 @@ int handle_curl_result(struct slot_results *results)
870876
credential_reject(&http_auth);
871877
return HTTP_NOAUTH;
872878
} else {
879+
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
880+
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
881+
#endif
873882
return HTTP_REAUTH;
874883
}
875884
} else {
@@ -986,6 +995,7 @@ static void extract_content_type(struct strbuf *raw, struct strbuf *type,
986995
strbuf_addstr(charset, "ISO-8859-1");
987996
}
988997

998+
989999
/* http_request() targets */
9901000
#define HTTP_REQUEST_STRBUF 0
9911001
#define HTTP_REQUEST_FILE 1

0 commit comments

Comments
 (0)