All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	David Turner <David.Turner@twosigma.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	"sandals@crustytoothpaste.net" <sandals@crustytoothpaste.net>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH] http(s): automatically try NTLM authentication first
Date: Thu, 23 Feb 2017 18:08:49 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1702231806340.3767@virtualbox> (raw)
In-Reply-To: <20170222213410.iak43asq775tzr42@sigill.intra.peff.net>

Hi Peff,

On Wed, 22 Feb 2017, Jeff King wrote:

> On Wed, Feb 22, 2017 at 01:16:33PM -0800, Junio C Hamano wrote:
> 
> > David Turner <David.Turner@twosigma.com> writes:
> > 
> > > Always, no.  For failed authentication (or authorization),
> > > apparently, yes.  I tested this by  setting the variable to false
> > > and then true, and trying to Push to a github repository which I
> > > didn't have write access to, with both an empty username
> > > (https://@:github.com/...) and no username (http://github.com/...).
> > > I ran this under GIT_CURL_VERBOSE=1 and I saw two 401 responses in
> > > the "http.emptyauth=true" case and one in the false case.  I also
> > > tried with a repo that I did have access to (first configuring the
> > > necessary tokens for HTTPS push access), and saw two 401 responses
> > > in *both* cases.  
> > 
> > Thanks; that matches my observation.  I do not think we care about
> > an extra roundtrip for the failure case, but as long as we do not
> > increase the number of roundtrip in the normal case, we can declare
> > that this is an improvement.  I am not quite sure where that extra
> > 401 comes from in the normal case, and that might be an indication
> > that we already are doing something wrong, though.
> 
> This patch drops the useless probe request:
> 
> diff --git a/http.c b/http.c
> index 943e630ea..7b4c2db86 100644
> --- a/http.c
> +++ b/http.c
> @@ -1663,6 +1663,9 @@ static int http_request(const char *url,
>  		curlinfo_strbuf(slot->curl, CURLINFO_EFFECTIVE_URL,
>  				options->effective_url);
>  
> +	if (results.auth_avail == CURLAUTH_BASIC)
> +		http_auth_methods = CURLAUTH_BASIC;
> +
>  	curl_slist_free_all(headers);
>  	strbuf_release(&buf);
>  
> 
> but setting http.emptyauth adds back in the useless request. I think
> that could be fixed by skipping the empty-auth thing when
> http_auth_methods does not have CURLAUTH_NEGOTIATE in it (or perhaps
> other methods need it to, so maybe skip it if _just_ BASIC is set).
> 
> I suspect the patch above could probably be generalized as:
> 
>   /* cut out methods we know the server doesn't support */
>   http_auth_methods &= results.auth_avail;
> 
> and let curl figure it out from there.

Maybe this patch (or a variation thereof) would also be able to fix this
problem with the patch:

	https://github.com/git-for-windows/git/issues/1034

Short version: for certain servers (that do *not* advertise Negotiate),
setting emptyauth to true will result in a failed fetch, without letting
the user type in their credentials.

Ciao,
Johannes

  reply	other threads:[~2017-02-23 17:10 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 17:39 [PATCH] http(s): automatically try NTLM authentication first David Turner
2017-02-22 20:19 ` Junio C Hamano
2017-02-22 21:04   ` David Turner
2017-02-22 21:16     ` Junio C Hamano
2017-02-22 21:34       ` Jeff King
2017-02-23 17:08         ` Johannes Schindelin [this message]
2017-02-23 19:06           ` Junio C Hamano
2017-02-23 19:42           ` Jeff King
2017-02-23 20:37             ` Junio C Hamano
2017-02-23 20:48               ` Jeff King
2017-02-25 11:51                 ` Johannes Schindelin
2017-02-22 23:34     ` brian m. carlson
2017-02-22 23:42       ` Jeff King
2017-02-23  2:15         ` Junio C Hamano
2017-02-23 19:11         ` Junio C Hamano
2017-02-23 19:35           ` Jeff King
2017-02-23  1:03       ` David Turner
2017-02-23  4:19         ` brian m. carlson
2017-02-23  9:13         ` Mantas Mikulėnas
2017-02-22 21:06   ` Jeff King
2017-02-22 21:25     ` Junio C Hamano
2017-02-22 21:35       ` Jeff King
2017-02-22 21:57         ` Junio C Hamano
2017-02-22 21:58           ` Jeff King
2017-02-22 22:35             ` Junio C Hamano
2017-02-22 23:33               ` Jeff King
2017-02-22 23:34                 ` [PATCH 1/2] http: restrict auth methods to what the server advertises Jeff King
2017-02-22 23:40                 ` [PATCH 2/2] http: add an "auto" mode for http.emptyauth Jeff King
2017-02-23  1:16                   ` David Turner
2017-02-23  1:37                     ` Jeff King
2017-02-23 16:31                       ` David Turner
2017-02-23 19:44                         ` Jeff King
2017-02-23 20:05                           ` David Turner
2017-02-25 11:48                       ` Johannes Schindelin
2017-02-25 19:15                         ` Jeff King
2017-02-25 19:18                           ` [PATCH] " Jeff King
2017-02-27 18:35                             ` Junio C Hamano
2017-02-28 10:18                               ` Johannes Schindelin

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=alpine.DEB.2.20.1702231806340.3767@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=David.Turner@twosigma.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    --cc=sunshine@sunshineco.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.