Skip to content

HTTPCLIENT-1748: fix for proxy authentication issue / branch 4.5.x - #52

Closed
sebastiencaille wants to merge 2 commits into
apache:4.5.xfrom
sebastiencaille:4.5.x
Closed

HTTPCLIENT-1748: fix for proxy authentication issue / branch 4.5.x#52
sebastiencaille wants to merge 2 commits into
apache:4.5.xfrom
sebastiencaille:4.5.x

Conversation

@sebastiencaille

Copy link
Copy Markdown

Hello,
Here is a pull request for HTTPCLIENT-1748 for httpclient 4.5.x. The first change is the fix, the second one is an improvement.

I also implemented the fix for httpclient5. Should I submit it as a separate pull request, or do you have a specific way to handle such case? (rebase, ...)

Thanks

@sebastiencaille sebastiencaille changed the title 4.5.x HTTPCLIENT-1748: fix for 4.5.x Jun 24, 2016
@sebastiencaille sebastiencaille changed the title HTTPCLIENT-1748: fix for 4.5.x HTTPCLIENT-1748: fix for proxy authentication issue / branch 4.5.x Jun 24, 2016
@ok2c

ok2c commented Jun 25, 2016

Copy link
Copy Markdown
Member

Sebastien
What was the reason for changing AuthScope class and including a URL attribute in the auth scope? Based on my reading of the HTTP spec authentication context is defined by the realm of the auth challenge, not by a request URI.
Oleg

@sebastiencaille

Copy link
Copy Markdown
Author

Hello

At first I tried to provide the proxy's url, but the applet was always asking for credentials.
It works fine when I provide the request URI.
Then, according to a breakpoint I put in Authenticator.requestPasswordAuthentication, the applet plugin uses the url of the jar files it wants to download.

I just checked the code of the openjdk... It looks like they are doing that, too
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/sun/net/www/protocol/http/HttpURLConnection.java#HttpURLConnection.getHttpProxyAuthentication%28sun.net.www.protocol.http.AuthenticationHeader%29 (line 2223)

My guess is that the other parameters are sufficient to define the realm of the auth challenge. That one is probably used to strengthen the security in some use cases (eg to reduce the risks of cross domain calls).

By the way, it looks like providing HTTP_TARGET_HOST is sufficient to fix my use case, but strictly speaking it should be the entire request URI (but at the moment I don't know how to get that one)...

Sebastien

@ok2c

ok2c commented Jun 27, 2016

Copy link
Copy Markdown
Member

Sebastien,
Nothing should stop you from getting the actual request URI by reading the HTTP_REQUEST attribute.

Adding the request URI to the AuthScope class looks conceptually wrong and should not be done simply because Oracle does it.

@sebastiencaille

Copy link
Copy Markdown
Author

Ok, I'll use HTTP_REQUEST

my point about the openjdk was just that we need to provide this value, nothing more...
At the moment I see it as a "security metadata" for AuthScope, which is required to make requestPasswordAuthentication work correctly in all cases.

As far as I get it, the other option is to add a parameter to CredentialsProvider.getCredentials...
eg getCredentials(AuthScope authscope, HttpContext httpContext).
But that's a much larger change...

Sebastien

@ok2c

ok2c commented Jun 28, 2016

Copy link
Copy Markdown
Member

I have no problem of what so ever with changing CredentialsProvider in 5.0 if it is justified.

@ok2c

ok2c commented Jun 28, 2016

Copy link
Copy Markdown
Member

I have a question. Why cannot you build the URL from AuthScope attributes if effectively you only need the authority part (scheme://host:port)?

@sebastiencaille

Copy link
Copy Markdown
Author

When the java application is run in an applet environment (and webstart, possibly), The Authenticator delegates the call to a com.sun.deploy.security.DeployAuthenticator . The DeployAuthenticator only works when the url parameter of requestPasswordAuthentication is the url I want to connect to (eg http://www.whatever.com - the jdk provides the full url, it works with the authority part), it does NOT work if the url parameter is the proxy url (http://myproxy:3128) - I guess the authentication is delegated to the browser, which needs this information for security reasons (maybe to prevent cross domain calls). Since the AuthScope only contains information about the proxy, the information needed to call requestPasswordAuthentication the "right" way is currently not available...

@ok2c

ok2c commented Aug 13, 2016

Copy link
Copy Markdown
Member

Obsoleted by #55. Please close

@pono pono closed this May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants