Skip to content

Commit 65ba75b

Browse files
committed
Merge branch 'bc/http-empty-auth'
Some authentication methods do not need username or password, but libcurl needs some hint that it needs to perform authentication. Supplying an empty username and password string is a valid way to do so, but you can set the http.[<url>.]emptyAuth configuration variable to achieve the same, if you find it cleaner. * bc/http-empty-auth: http: add option to try authentication without username
2 parents 97c49af + 121061f commit 65ba75b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Documentation/config.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,12 @@ http.proxyAuthMethod::
16481648
* `ntlm` - NTLM authentication (compare the --ntlm option of `curl(1)`)
16491649
--
16501650

1651+
http.emptyAuth::
1652+
Attempt authentication without seeking a username or password. This
1653+
can be used to attempt GSS-Negotiate authentication without specifying
1654+
a username in the URL, as libcurl normally requires a username for
1655+
authentication.
1656+
16511657
http.cookieFile::
16521658
File containing previously stored cookie lines which should be used
16531659
in the Git http session, if they match the server. The file format

http.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static int curl_save_cookies;
9292
struct credential http_auth = CREDENTIAL_INIT;
9393
static int http_proactive_auth;
9494
static const char *user_agent;
95+
static int curl_empty_auth;
9596

9697
#if LIBCURL_VERSION_NUM >= 0x071700
9798
/* Use CURLOPT_KEYPASSWD as is */
@@ -304,14 +305,22 @@ static int http_options(const char *var, const char *value, void *cb)
304305
if (!strcmp("http.useragent", var))
305306
return git_config_string(&user_agent, var, value);
306307

308+
if (!strcmp("http.emptyauth", var)) {
309+
curl_empty_auth = git_config_bool(var, value);
310+
return 0;
311+
}
312+
307313
/* Fall back on the default ones */
308314
return git_default_config(var, value, cb);
309315
}
310316

311317
static void init_curl_http_auth(CURL *result)
312318
{
313-
if (!http_auth.username)
319+
if (!http_auth.username) {
320+
if (curl_empty_auth)
321+
curl_easy_setopt(result, CURLOPT_USERPWD, ":");
314322
return;
323+
}
315324

316325
credential_fill(&http_auth);
317326

@@ -836,7 +845,7 @@ struct active_request_slot *get_active_slot(void)
836845
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
837846
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
838847
#endif
839-
if (http_auth.password)
848+
if (http_auth.password || curl_empty_auth)
840849
init_curl_http_auth(slot->curl);
841850

842851
return slot;

0 commit comments

Comments
 (0)