From: Jeff King <peff@peff.net>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org,
"Dan Langille (dalangil)" <dalangil@cisco.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] remote-curl: fall back to Basic auth if Negotiate fails
Date: Sat, 3 Jan 2015 06:19:23 -0500 [thread overview]
Message-ID: <20150103111922.GB27793@peff.net> (raw)
In-Reply-To: <1420142187-1025433-1-git-send-email-sandals@crustytoothpaste.net>
On Thu, Jan 01, 2015 at 07:56:27PM +0000, brian m. carlson wrote:
> +void disable_passwordless_auth(struct active_request_slot *slot)
> +{
> +#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
> +#define HTTP_AUTH_PASSWORDLESS (CURLAUTH_GSSNEGOTIATE)
> + curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH,
> + CURLAUTH_ANY & ~HTTP_AUTH_PASSWORDLESS);
> +#endif
> +}
I like that you are trying to put a layer of abstraction around what
"passwordless" means here, but it seems like there are two layers. The
function itself abstracts the idea, and then there is an extra
HTTP_AUTH_PASSWORDLESS macro. Since the concept is already confined to
this function and used only once, it might be more readable to simply
get rid of HTTP_AUTH_PASSWORD.
> @@ -1035,6 +1047,9 @@ static int http_request(const char *url,
> curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
> curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip");
>
> + if (!http_passwordless_auth)
> + disable_passwordless_auth(slot);
> +
> ret = run_one_slot(slot, &results);
>
> if (options && options->content_type) {
> @@ -1139,6 +1154,7 @@ static int http_request_reauth(const char *url,
> }
>
> credential_fill(&http_auth);
> + http_passwordless_auth = 0;
>
> return http_request(url, result, target, options);
> }
This pattern gets repeated in several places. Now that
http_passwordless_auth is a global, can we handle it automatically for
the callers, as below (which, aside from compiling, is completely
untested by me)?
Note that this is in a slightly different boat than credential_fill.
Ideally we would also handle picking up credentials on behalf of the
callers of get_curl_handle/handle_curl_result. But that may involve
significant work and/or prompting the user, which we _must_ avoid if we
do not know if we are going to retry the request (and only the caller
knows that for sure). However, in the case of http_passwordless_auth, we
are just setting a flag, so it's OK to do it preemptively.
diff --git a/http.c b/http.c
index 040f362..2bbcdf1 100644
--- a/http.c
+++ b/http.c
@@ -62,6 +62,8 @@ static const char *user_agent;
static struct credential cert_auth = CREDENTIAL_INIT;
static int ssl_cert_password_required;
+/* Should we allow non-password-based authentication (e.g. GSSAPI)? */
+static int http_passwordless_auth = 1;
static struct curl_slist *pragma_header;
static struct curl_slist *no_pragma_header;
@@ -318,7 +320,12 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
#endif
#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
- curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+ {
+ int flags = CURLAUTH_ANY;
+ if (!http_passwordless_auth)
+ flags &= ~CURLAUTH_GSSNEGOTIATE;
+ curl_easy_setopt(result, CURLOPT_HTTPAUTH, flags);
+ }
#endif
if (http_proactive_auth)
@@ -870,6 +877,7 @@ int handle_curl_result(struct slot_results *results)
credential_reject(&http_auth);
return HTTP_NOAUTH;
} else {
+ http_passwordless_auth = 0;
return HTTP_REAUTH;
}
} else {
Note that you could probably drop http_passwordless_auth completely, and
just keep a:
static int http_auth_methods = CURLAUTH_ANY;
and then drop CURLAUTH_GSSNEGOTIATE from it instead of setting the
passwordless_auth flag to 0 (again, it happens in one place, so I don't
know that it needs an extra layer of abstraction).
-Peff
next prev parent reply other threads:[~2015-01-03 11:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-18 22:19 git-http-backend auth via Kerberos Dan Langille (dalangil)
2014-12-18 22:54 ` brian m. carlson
2014-12-19 15:07 ` Dan Langille (dalangil)
2014-12-19 15:50 ` Dan Langille (dalangil)
2014-12-19 16:07 ` Dan Langille (dalangil)
2014-12-19 20:16 ` brian m. carlson
2014-12-19 20:57 ` Dan Langille (dalangil)
2014-12-27 4:01 ` [PATCH] remote-curl: fall back to Basic auth if Negotiate fails brian m. carlson
2014-12-27 17:56 ` Jeff King
2014-12-27 21:09 ` brian m. carlson
2014-12-27 21:29 ` Jeff King
2014-12-28 0:05 ` brian m. carlson
2015-01-01 19:56 ` [PATCH v2] " brian m. carlson
2015-01-03 11:19 ` Jeff King [this message]
2015-01-03 17:45 ` brian m. carlson
2015-01-03 20:14 ` Jeff King
2015-01-05 16:02 ` Dan Langille (dalangil)
2015-01-05 21:23 ` Dan Langille (dalangil)
2015-01-05 23:53 ` brian m. carlson
2015-01-06 15:31 ` Dan Langille (dalangil)
2015-01-06 15:41 ` Dan Langille (dalangil)
2015-01-06 16:07 ` Dan Langille (dalangil)
2015-01-08 0:02 ` brian m. carlson
2015-01-08 0:29 ` [PATCH v3] " brian m. carlson
2015-01-20 16:40 ` Dan Langille (dalangil)
2015-01-21 0:22 ` Junio C Hamano
2015-01-22 14:47 ` Dan Langille (dalangil)
2015-02-17 23:05 ` Dan Langille (dalangil)
2015-02-17 23:36 ` Junio C Hamano
2015-02-18 16:17 ` Dan Langille (dalangil)
2015-02-19 20:35 ` brian m. carlson
2015-02-24 21:03 ` Dan Langille (dalangil)
2015-02-25 20:59 ` Dan Langille (dalangil)
2015-03-10 18:05 ` Dan Langille (dalangil)
2015-03-10 22:29 ` brian m. carlson
2015-03-11 19:33 ` Dan Langille (dalangil)
2015-03-11 21:59 ` brian m. carlson
2015-03-12 13:09 ` Dan Langille (dalangil)
2015-01-05 13:12 ` [PATCH] " Dan Langille (dalangil)
[not found] <pull.849.git.1611921008282.gitgitgadget@gmail.com>
2021-02-16 16:57 ` [PATCH v2] remote-curl: fall back to basic " Christopher via GitGitGadget
[not found] ` <xmqq35xvpr8q.fsf@gitster.c.googlers.com>
2021-03-22 16:08 ` Christopher Schenk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150103111922.GB27793@peff.net \
--to=peff@peff.net \
--cc=dalangil@cisco.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).