Skip to content
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

add basic auth support to proxy chain #329

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add basic auth support to proxy chain #329

wants to merge 1 commit into from

Conversation

rrauschenbach
Copy link

I want to be able to create a proxy chain to a remote proxy which is not under my control and is configured to use http basic authentication.

Here is the usage code for the changes I made.

bootstrap.withChainProxyManager(new ChainedProxyManager() {

    @Override
    public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
        chainedProxies.add(new ChainedProxyAdapter() {

            @Override
            public InetSocketAddress getChainedProxyAddress() {
                try {
                    return new InetSocketAddress(InetAddress.getByName(chainingProxyHost), chainingProxyPort);
                } catch (UnknownHostException uhe) {
                    throw new RuntimeException(uhe);
                }
            }

            @Override
            public String getBasicAuthUser() {
                return chainingProxyUser;
            }

            @Override
            public String getBasicAuthPassword() {
                return chainingProxyPass;
            }

        });
    }
});

@jekh
Copy link
Collaborator

jekh commented Dec 19, 2016

Chained proxy authorization is already supported. There's no need to change the LittleProxy code at all, simply add a filter to the chained proxy manager. Here's an example of how BMP does this.

@rrauschenbach
Copy link
Author

Thank you for the fast answer and the example. It will do what I want and it is totally ok for me to close this PR.

What I didn't like at the example is that it's a very generic way to do something special. It's not intuitive to implement the filter method to do authentication and it results in a code that is difficult to understand and is doing things I would expect has to be done by the framework.

By the way, having two methods which depends to each other, as I suggest, is also not a beauty solution and way too special. I would prefere some authentication interface which can be returned by a new ChainedProxy method which would be generic enough to allow different authentication types but results in less usage code with a higher knowability. But this is a question of architecture I can't really estimate with my little knowledge about LittleProxy.

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.

None yet

2 participants