You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Xavier López <xa...@gmail.com> on 2017/03/06 16:41:27 UTC

Camel Http4 using basic auth and proxy auth

I've been trying to use Apache Camel's Http4 component to connect to a
HTTPS URL that needs Basic authentication. The connection needs to be
done through an authenticated HTTP proxy.

So, according to the docs at http://camel.apache.org/http4.html, I
configure the Camel endpoint like this:

    .toD("https4://target.host/resource?
            bridgeEndpoint=true
            &mapHttpMessageBody=false

            &proxyAuthHost=my.proxy.host
            &proxyAuthPort=myProxyPort
            &proxyAuthUsername=proxyUser
            &proxyAuthPassword=proxyPassword
            &proxyAuthScheme=http4

            &authenticationPreemptive=true
            &authUsername=myUser
            &authPassword=myPassword")

Which results in a "403 - Forbidden" response from the target server.
Looking through the "org.apache.http.wire" logs, it shows that the
proxy credentials proxyUser/proxyPassword are forwarded to the target
server instead of the intended myUser/myPassword in the
"Authorization" header instead .

Debugging the source for CompositeHTTPConfigurer.configureHttpClient,
ProxyHttpClientConfigurer.configureHttpClient and
BasicAuthenticationHttpClientConfigurer.configureHttpClient, it seems
that both configurers are setting their credentials to the
HttpClientBuilder by means of setDefaultCredentialsProvider. Mostly
because they do little more than set that defaultCredentialsProvider
on the HttpClientBuilder, that gets overwritten.

It seems it's working fine if the proxy auth header is provided
independently from the Http4 component by means of
setHeader("Proxy-Authorization", simple("Basic <base64>")).

Looks like it could be a bug in Camel's Http4 component? Or am I
missing something? This is Camel 2.18.2 with Spring Boot 1.5.1.RELEASE

I've also posted this question over at SO
(http://stackoverflow.com/questions/42629981/) but figured it'd get
better attention here. Sorry for the repost.

Best regards,
Xavi

Re: Camel Http4 using basic auth and proxy auth

Posted by Claus Ibsen <cl...@gmail.com>.
Yeah sounds like a little bug. You are welcome to log a JIRA and
provide a PR with a fix. You have a system where you can test it.
http://camel.apache.org/contributing

On Mon, Mar 6, 2017 at 5:41 PM, Xavier López <xa...@gmail.com> wrote:
> I've been trying to use Apache Camel's Http4 component to connect to a
> HTTPS URL that needs Basic authentication. The connection needs to be
> done through an authenticated HTTP proxy.
>
> So, according to the docs at http://camel.apache.org/http4.html, I
> configure the Camel endpoint like this:
>
>     .toD("https4://target.host/resource?
>             bridgeEndpoint=true
>             &mapHttpMessageBody=false
>
>             &proxyAuthHost=my.proxy.host
>             &proxyAuthPort=myProxyPort
>             &proxyAuthUsername=proxyUser
>             &proxyAuthPassword=proxyPassword
>             &proxyAuthScheme=http4
>
>             &authenticationPreemptive=true
>             &authUsername=myUser
>             &authPassword=myPassword")
>
> Which results in a "403 - Forbidden" response from the target server.
> Looking through the "org.apache.http.wire" logs, it shows that the
> proxy credentials proxyUser/proxyPassword are forwarded to the target
> server instead of the intended myUser/myPassword in the
> "Authorization" header instead .
>
> Debugging the source for CompositeHTTPConfigurer.configureHttpClient,
> ProxyHttpClientConfigurer.configureHttpClient and
> BasicAuthenticationHttpClientConfigurer.configureHttpClient, it seems
> that both configurers are setting their credentials to the
> HttpClientBuilder by means of setDefaultCredentialsProvider. Mostly
> because they do little more than set that defaultCredentialsProvider
> on the HttpClientBuilder, that gets overwritten.
>
> It seems it's working fine if the proxy auth header is provided
> independently from the Http4 component by means of
> setHeader("Proxy-Authorization", simple("Basic <base64>")).
>
> Looks like it could be a bug in Camel's Http4 component? Or am I
> missing something? This is Camel 2.18.2 with Spring Boot 1.5.1.RELEASE
>
> I've also posted this question over at SO
> (http://stackoverflow.com/questions/42629981/) but figured it'd get
> better attention here. Sorry for the repost.
>
> Best regards,
> Xavi



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2