diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-02-24 13:25:57 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-24 13:25:57 -0800 |
commit | 65ba75ba7daae3298139f18cf866a23d01f4dd48 (patch) | |
tree | 9b2dfd15024eb48e2bdbce57cacfeb118de75820 /http.c | |
parent | 97c49af6a7c30ca8bf7183bdac8345ca3f8abe56 (diff) | |
parent | 121061f67fd47aed5b2f3a7deb82af15215636bd (diff) | |
download | git-65ba75ba7daae3298139f18cf866a23d01f4dd48.tar.gz |
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
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -92,6 +92,7 @@ static int curl_save_cookies; struct credential http_auth = CREDENTIAL_INIT; static int http_proactive_auth; static const char *user_agent; +static int curl_empty_auth; #if LIBCURL_VERSION_NUM >= 0x071700 /* Use CURLOPT_KEYPASSWD as is */ @@ -304,14 +305,22 @@ static int http_options(const char *var, const char *value, void *cb) if (!strcmp("http.useragent", var)) return git_config_string(&user_agent, var, value); + if (!strcmp("http.emptyauth", var)) { + curl_empty_auth = git_config_bool(var, value); + return 0; + } + /* Fall back on the default ones */ return git_default_config(var, value, cb); } static void init_curl_http_auth(CURL *result) { - if (!http_auth.username) + if (!http_auth.username) { + if (curl_empty_auth) + curl_easy_setopt(result, CURLOPT_USERPWD, ":"); return; + } credential_fill(&http_auth); @@ -836,7 +845,7 @@ struct active_request_slot *get_active_slot(void) #ifdef LIBCURL_CAN_HANDLE_AUTH_ANY curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods); #endif - if (http_auth.password) + if (http_auth.password || curl_empty_auth) init_curl_http_auth(slot->curl); return slot; |