Skip to content

Commit 121061f

Browse files
bk2204gitster
authored andcommitted
http: add option to try authentication without username
Performing GSS-Negotiate authentication using Kerberos does not require specifying a username or password, since that information is already included in the ticket itself. However, libcurl refuses to perform authentication if it has not been provided with a username and password. Add an option, http.emptyAuth, that provides libcurl with an empty username and password to make it attempt authentication anyway. Signed-off-by: Junio C Hamano <[email protected]>
1 parent a08595f commit 121061f

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
@@ -1600,6 +1600,12 @@ http.proxy::
16001600
`curl(1)`). This can be overridden on a per-remote basis; see
16011601
remote.<name>.proxy
16021602

1603+
http.emptyAuth::
1604+
Attempt authentication without seeking a username or password. This
1605+
can be used to attempt GSS-Negotiate authentication without specifying
1606+
a username in the URL, as libcurl normally requires a username for
1607+
authentication.
1608+
16031609
http.cookieFile::
16041610
File containing previously stored cookie lines which should be used
16051611
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
@@ -67,6 +67,7 @@ static int curl_save_cookies;
6767
struct credential http_auth = CREDENTIAL_INIT;
6868
static int http_proactive_auth;
6969
static const char *user_agent;
70+
static int curl_empty_auth;
7071

7172
#if LIBCURL_VERSION_NUM >= 0x071700
7273
/* Use CURLOPT_KEYPASSWD as is */
@@ -273,14 +274,22 @@ static int http_options(const char *var, const char *value, void *cb)
273274
if (!strcmp("http.useragent", var))
274275
return git_config_string(&user_agent, var, value);
275276

277+
if (!strcmp("http.emptyauth", var)) {
278+
curl_empty_auth = git_config_bool(var, value);
279+
return 0;
280+
}
281+
276282
/* Fall back on the default ones */
277283
return git_default_config(var, value, cb);
278284
}
279285

280286
static void init_curl_http_auth(CURL *result)
281287
{
282-
if (!http_auth.username)
288+
if (!http_auth.username) {
289+
if (curl_empty_auth)
290+
curl_easy_setopt(result, CURLOPT_USERPWD, ":");
283291
return;
292+
}
284293

285294
credential_fill(&http_auth);
286295

@@ -695,7 +704,7 @@ struct active_request_slot *get_active_slot(void)
695704
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
696705
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
697706
#endif
698-
if (http_auth.password)
707+
if (http_auth.password || curl_empty_auth)
699708
init_curl_http_auth(slot->curl);
700709

701710
return slot;

0 commit comments

Comments
 (0)