From: Jeff King <peff@peff.net>
To: Sam Vilain <sam@vilain.net>
Cc: Nelson Benitez Leon <nelsonjesus.benitez@seap.minhap.es>,
git@vger.kernel.org
Subject: Re: [PATCH v2 3/3] http: when proxy url has username but no password, ask for password
Date: Thu, 1 Mar 2012 16:58:12 -0500 [thread overview]
Message-ID: <20120301215812.GG17631@sigill.intra.peff.net> (raw)
In-Reply-To: <4F4FB69C.7000708@vilain.net>
On Thu, Mar 01, 2012 at 09:49:16AM -0800, Sam Vilain wrote:
> > if (curl_http_proxy) {
> >- curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
> >+ credential_from_url(&proxy_auth, curl_http_proxy);
> >+ if (proxy_auth.username != NULL&& proxy_auth.password == NULL) {
> >+ /* proxy string has username but no password, ask for password */
> >+ struct strbuf pbuf = STRBUF_INIT;
> >+ credential_fill(&proxy_auth);
>
> Wouldn't it be better to wait until the proxy returns a 403 before
> assuming that the proxy setting is incorrect/missing a password?
> What if the administrator expects the user to fill in both the
> username and password? That is the behaviour of a web browser.
>
> Also, I think you should wait until that 403 to detect whether the
> proxy setting came from the environment, and only load it explicitly
> then.
It's worth looking at what the http auth code does here.
In the beginning (2005), git saw that there was a username in the URL
and prompted for a password unconditionally before making a request. If
you didn't have a username, you didn't do auth, period.
Later, 42653c0 (Prompt for a username when an HTTP request 401s,
2010-04-01) taught git to handle 401s, for when the URL does not contain
a username. We kept the unconditional pre-prompt, though; it has the
nice side effect of avoiding a round-trip to the server.
Then, in 986bbc0 (http: don't always prompt for password, 2011-11-04),
the unconditional pre-prompt was taken away. While avoiding the
round-trip is nice, it circumvented curl's reading of the .netrc file,
which means git would prompt unnecessarily, even when curl could
eventually read out of the netrc.
However, the code for dumb http push-over-dav doesn't handle the 401
properly. As a work-around, a4ddbc3 (http-push: enable "proactive auth",
2011-12-13) re-enabled the pre-prompt, but only for the code paths that
need it (and those code paths are now broken for .netrc, as everything
was before 986bbc0). This is a hack, and in the long run it would be
nice to have everything handle 401s properly, but the dav code is
somewhat obsolete these days, and I suspect nobody really wants to
overhaul it.
Complicating all of this is the fact that I think Nelson's original
patch was based on an older, pre-986bbc0 version of git, which is why he
followed the pre-prompt route, copying the style of regular http auth.
So there's the history lesson. What should proxy auth do?
1. Definitely respond to HTTP 407 by prompting on the fly; this code
should go along-side the HTTP 401 code in http.c.
2. Definitely do the pre-prompt thing when http_proactive_auth is set
(which is used only by http-push). Unless somebody really feels
like re-writing http-push to handle retries for authentication.
3. Consider doing the pre-prompt thing when http_proactive_auth is not
set. This can save a round-trip, but we should not do it if there
is a good reason not to. The two possible reasons I can think of
are:
a. Like http auth, if curl will read the proxy credentials from
.netrc, then we should not do it for the same reasons
mentioned in 986bbc0.
b. If people realistically have proxy URLs with usernames but do
_not_ want to ask for a password, then the prompt will be
annoying. I'm not sure that anybody expects that.
I consider (3) to be a "meh, if you are really interested in looking
into this" step, as it is really just a possible optimization (and I
suspect curl _does_ use netrc for proxy credentials, but I haven't
checked). But we definitely want to get (1) and (2) right.
-Peff
next prev parent reply other threads:[~2012-03-01 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 18:22 [PATCH v2 3/3] http: when proxy url has username but no password, ask for password Nelson Benitez Leon
2012-03-01 17:49 ` Sam Vilain
2012-03-01 21:58 ` Jeff King [this message]
2012-03-02 13:33 ` Nelson Benitez Leon
2012-03-02 12:45 ` Jeff King
2012-03-02 14:05 ` Nelson Benitez Leon
2012-03-02 13:52 ` Jeff King
2012-03-01 19:16 ` Junio C Hamano
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=20120301215812.GG17631@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=nelsonjesus.benitez@seap.minhap.es \
--cc=sam@vilain.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).