Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Protocol is hard coded for discovered nodes #196

Closed
kramer opened this issue Apr 1, 2015 · 10 comments
Closed

Protocol is hard coded for discovered nodes #196

kramer opened this issue Apr 1, 2015 · 10 comments
Labels

Comments

@kramer
Copy link
Member

kramer commented Apr 1, 2015

Protocol for newly discovered nodes is hard coded as http by NodeChecker.

reported by @mlazzari-tribecube in #195

@kramer kramer added the bug label Apr 1, 2015
@mlazzari-tribecube
Copy link

Please also notice that you are also losing any authentication used in the first connection URL provided via the client configuration builder or add server method. I think that also authentication credentials should be passed separately to the client confing so that they can be used along with the selected protocol when reading creating the connection url during node check.

(cross posting from #195, sorry)

@kramer
Copy link
Member Author

kramer commented Apr 2, 2015

authentication ... in the ... URL

Well that was already a workaroundy way of passing the auth details 😛, CredentialsProvider is the "ideal" way to do it and that would work with the new discovered hosts (if I'm not mistaken). I would strongly advise against building anything around the URL passed auth details and instead we should make it easier to work with CredentialsProvider for the user (part of #179) and make sure that plays along nicely with discovered hosts.

@mlazzari-tribecube
Copy link

It is still unclear to me how can I provide the CredentialsProvider during the http client creation in JestClientFactory

    private CloseableHttpClient createHttpClient(HttpClientConnectionManager connectionManager) {
        return configureHttpClient(HttpClients.custom()
                .setConnectionManager(connectionManager)
                .setDefaultRequestConfig(createRequestConfig()))
                .setRoutePlanner(getRoutePlanner())
                .build();
    }

to my knowledge this is where I can set my CredentialsProvider. As per Apache's example

        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(
                new AuthScope("localhost", 443),
                new UsernamePasswordCredentials("username", "password"));
        CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCredentialsProvider(credsProvider)
                .build();

@kramer
Copy link
Member Author

kramer commented Apr 2, 2015

Currently you can modify CredentialsProvider in a not so fancy way as shown here earlier; after #179 we'll have a nicer way of setting it through factory.

@kramer
Copy link
Member Author

kramer commented May 1, 2015

As ES does not have built-in HTTPS support and it can only be achieved with a plugin or a custom layer on top of ES, it seems to me there is no way to programmatically tell if a discovered node supports HTTPS; please correct me if I'm wrong.

In that case my solution would be to provide a method in ClientConfig to set a default protocol for discovered nodes (manually).

@mlazzari-tribecube
Copy link

That's correct but since 3707ee1 commit it is my understanding that there is a proper way to specify authentication (and, protocol): this means that the same authentication process should be applied to any of the discovered nodes, thus including the protocol that needs to be used to connect to the discovered node.

@kramer
Copy link
Member Author

kramer commented May 1, 2015

Yeah the authentication details provided earlier will be used for discovered nodes too (automatically as those details are registered on HttpClient itself). But there is still no way to pass protocol other than within the url (to jest) therefore I propose something like:

factory.setHttpClientConfig(
    new HttpClientConfig.Builder("http://localhost:9200")
        .defaultCredentials("global_user", "global_password")
        .defaultProtocol("https")
        .build()
);

@mlazzari-tribecube
Copy link

Understood. That should certainly do the trick.

2015-05-01 16:54 GMT+02:00 Cihat Keser notifications@github.com:

Yeah the authentication details provided earlier will be used for
discovered nodes too (automatically as those details are registered on
HttpClient itself). But there is still no way to pass protocol other than
within the url (to jest) therefore I propose something like:

factory.setHttpClientConfig(
new HttpClientConfig.Builder("http://localhost:9200")
.defaultCredentials("global_user", "global_password")
.defaultProtocol("https")
.build()
);


Reply to this email directly or view it on GitHub
#196 (comment).

Manuel Lazzari

Senior Software Engineer | Tribecube
manuel.lazzari@tribecube.com | www.tribecube.com

@kramer kramer closed this as completed in 25d6ce3 May 11, 2015
@mlazzari-tribecube
Copy link

Awesome! Any hints on when a new jar will be released?

2015-05-11 16:44 GMT+02:00 Cihat Keser notifications@github.com:

Closed #196 #196 via 25d6ce3
25d6ce3
.


Reply to this email directly or view it on GitHub
#196 (comment).

Manuel Lazzari

Senior Software Engineer | Tribecube
manuel.lazzari@tribecube.com | www.tribecube.com

@kramer
Copy link
Member Author

kramer commented May 11, 2015

This weekend (as posted in our awesome changelog 👅 )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants