New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oxAuth client should support HTTP proxy #9

Open
yurem opened this Issue Jan 30, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@yurem
Contributor

yurem commented Jan 30, 2015

This sample code allows to create HttpClient which works through proxy server

    public static HttpClient createProxyHttpClient(String proxyHost, int proxyPort, String proxyUser, String proxyPassword) throws KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException {
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
        registry.register(new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory()));

        ClientConnectionManager clientConnectionManager = new PoolingClientConnectionManager(registry);
        DefaultHttpClient httpClient = new DefaultHttpClient(clientConnectionManager);
        httpClient.getParams().setParameter(org.apache.http.conn.params.ConnRoutePNames.DEFAULT_PROXY,
                new HttpHost(proxyHost, proxyPort, "http"));

        // The proxy has optional authentication. The authentication information was set using the following code:
        if (StringHelper.isNotEmpty(proxyUser) && StringHelper.isNotEmpty(proxyPassword)) {
            httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort),
                    new UsernamePasswordCredentials(proxyUser, proxyPassword));
        }

        return httpClient;
    }

Also all oxAuth clients allows to set specified executor. Hence in order to use proxy client we need to do next for example:

        // Build client executor to use proxy
        HttpClient httpClient = createProxyHttpClient(proxyHost, proxyPort, proxyUser, proxyPassword);
        ClientExecutor clientExecutor = createClientExecutor(httpClient);
        authorizeClient.setExecutor(clientExecutor);

I think we can do than automatically.

Base client can detect if there are system properties with proxy configuration and use it if needed : -Dhttp.proxyHost=proxy.server.com -Dhttp.proxyPort=80, etc...

@yurem

This comment has been minimized.

Contributor

yurem commented Jan 30, 2015

Alternatively we can try to next:

  1. Create default executor
  2. get client
  3. set client parameters
    httpClient.getParams().setParameter(org.apache.http.conn.params.ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, proxyPort, "http"));
    and
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxyHost, proxyPort), new UsernamePasswordCredentials(proxyUser, proxyPassword));
@willow9886

This comment has been minimized.

Contributor

willow9886 commented Jan 13, 2016

@yurem do we need to keep this issue open?

@willow9886 willow9886 modified the milestones: CE 3.2.0, CE 3.1.0 Apr 5, 2017

@aliaksander-samuseu

This comment has been minimized.

Contributor

aliaksander-samuseu commented Apr 5, 2017

Quoting @yurem :

oxAuth server should also be able to work with a web proxy
I also think in the next versions we should implement additional parameters, like -Dhttp.proxyHost=proxy.server.com -Dhttp.proxyPort=80 - this way we won't need to change code much

@aliaksander-samuseu

This comment has been minimized.

Contributor

aliaksander-samuseu commented Apr 10, 2017

@yurem @willow9886

The reason we revisited it now after two years was because of this ticket
User didn't have issues when he was using the gplus custom auth script when machine where Gluu was installed was connected to Internet directly, but when it was placed in DMZ from where Internet could be only accessed through web proxy requiring user/pass authentication, it failed to access Google's servers. Setting default systems proxy settings didn't help, though with curl they could utilize them and traverse proxy successfully.

@yurem yurem modified the milestones: CE 3.1.0, CE 3.2.0 Aug 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment