aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Preemptive proxy authentication

Open itsnagaraj opened this issue 6 years ago • 1 comments

As part of our project we are trying to connect to S3 via proxy using preemptive authentication for proxy. Below is the snippet for the same

config.withProxyUsername(username) .withProxyPassword(password) .withProxyAuthenticationMethods(Arrays.asList(ProxyAuthenticationMethod.BASIC)) .withPreemptiveBasicProxyAuth(true) .withProxyProtocol(Protocol.HTTP);

After debugging through the code I can only see that Authorization header is being set with proxy username and password instead Proxy-Authorization being set with the same details.

This relates to issue https://issues.apache.org/jira/browse/HTTPCLIENT-1599?focusedCommentId=14278911&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14278911

The fix would be to update the method private static void addPreemptiveAuthenticationProxy(HttpClientContext clientContext, HttpClientSettings settings) {

    if (settings.isPreemptiveBasicProxyAuth()) {
        HttpHost targetHost = new HttpHost(settings.getProxyHost(), settings
                .getProxyPort());
        final CredentialsProvider credsProvider = newProxyCredentialsProvider(settings);
        // Create AuthCache instance
        AuthCache authCache = new BasicAuthCache();
        // Generate BASIC scheme object and add it to the local auth cache
        BasicScheme basicAuth = new BasicScheme();
        authCache.put(targetHost, basicAuth);

        clientContext.setCredentialsProvider(credsProvider);
        clientContext.setAuthCache(authCache);
    }
}

in class com.amazonaws.http.apache.utils.ApacheUtils to set the challengeState.

Meanwhile It will be great if you can suggest a workaround.

itsnagaraj avatar May 08 '19 04:05 itsnagaraj

@itsnagaraj Apologies for taking so long to get a response. Marking this as a bug.

As the team is focused in developing Java SDK v2 features this has a low chance of being fixed in v1. I don't know without checking the code if Java SDK v2 has the same issue.

debora-ito avatar Jun 15 '22 22:06 debora-ito