hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Proxy Authentication Strategy
Date Sat, 09 Apr 2016 09:44:49 GMT
On Thu, 2016-04-07 at 17:54 +0000, Mark A. Claassen wrote:
> Apache HTTPClient 4.4.1
> I was doing some more tests with proxy authentication and I ran into something I didn't
expect.  AuthenticationStrategyImpl goes though the list of schemes ( SPNEGO, NTLM, ...) to
find the ones that have "authentications".  However, this goes through all of them and does
not stop after it gets one.
> I created a CredentialsProvider that prompts the user for a username and password for
certain schemes.  I was surprised to find out that this made my password dialog appeared too
often.  I configured my proxy server to allow for NTLM and DIGEST authentication schemes.
 Then using my HttpClient, I thought that if NTLM was higher in priority, and there were credentials
for that, it would not continue to ask for credentials for the DIGEST scheme.  However, it
always goes through the whole list.  Is this supposed to be this way? 

It is. AuthenticationStrategyImpl does so to identify all auth schemes
that can potentially be used to respond to the authentication challenges
sent by the server. Naturally it can only do so if there are credentials
matching the actual authentication scope.  

> Does this make sense with how proxy servers work?  In my case, configuring the proxy
server to allow NTML and DIGEST authentication means that it will allow access if *either*
is specified, and does not require both.
> It would be nice if AuthenticationStrategyImpl would stop searching once it found something,
however there does not seem to be an easy way to handle this.  This makes me think I might
be doing something wrong.  I thought a custom CredentialProvider would be the correct place
to code in a password dialog.  But maybe there is a better "hook" I can use to bring up the
dialog, and then just put the information in the CredentialsProvider.  Is there a better place
to put this code?
> It seems the only way to handle this is to re-write AuthenticationStrategyImpl, adding
a single line so it will stop after the first non-null credentials are returned.

There should be nothing stopping you from returning the same creds
multiple times. You just need to make your implementation of
CredentialsProvider a little smarter.


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message