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

Feature Request: Add support for authentication for Elasticsearch #93

Open
karatekaneen opened this issue Apr 23, 2024 · 0 comments
Open

Comments

@karatekaneen
Copy link
Contributor

TL;DR: It would be nice to be able to pass headers to Elasticsearch

Description

When trying out the changes from #92 I provisioned an Elasticsearch instance with auth enabled and it did not work as expected. Since there are no way to add custom headers I tried to use the URL basic authentication instead but it did not work.

Values I tried:

  • https://elastic.company.internal:9200 - "failed: [security_exception] missing authentication credentials for REST request"
  • https://username:[email protected]:9200 - "invalid IPv6 address literal"
  • username:[email protected]:9200 - "invalid IPv6 address literal"
Stacktrace
ERROR [2024-04-23 13:24:42,129] com.scienceminer.glutton.indexing.ElasticSearchIndexer: Create index failed
! java.net.UnknownHostException: elastic:[email protected]: invalid IPv6 address literal
! at java.base/java.net.InetAddress.invalidIPv6LiteralException(InetAddress.java:1391)
! at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1361)
! at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1307)
! at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
! at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:666)
! at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:637)
! at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:474)
! at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:280)
! at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:295)
! at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:381)
! at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:130)
! at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.execute(CloseableHttpAsyncClientBase.java:116)
! at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:138)
! at org.elasticsearch.client.RestClient.performRequest(RestClient.java:300)
! ... 12 common frames omitted
! Causing: java.io.IOException: elastic:[email protected]: invalid IPv6 address literal
! at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:939)
! at org.elasticsearch.client.RestClient.performRequest(RestClient.java:304)
! at org.elasticsearch.client.RestClient.performRequest(RestClient.java:292)
! at co.elastic.clients.transport.rest_client.RestClientHttpClient.performRequest(RestClientHttpClient.java:91)
! at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:144)
! at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.create(ElasticsearchIndicesClient.java:266)
! at com.scienceminer.glutton.indexing.ElasticSearchIndexer.createIndex(ElasticSearchIndexer.java:123)
! at com.scienceminer.glutton.indexing.ElasticSearchIndexer.setupIndex(ElasticSearchIndexer.java:338)
! at com.scienceminer.glutton.command.LoadCrossrefCommand.run(LoadCrossrefCommand.java:94)
! at com.scienceminer.glutton.command.LoadCrossrefCommand.run(LoadCrossrefCommand.java:50)
! at io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
! at io.dropwizard.core.cli.Cli.run(Cli.java:78)
! at io.dropwizard.core.Application.run(Application.java:94)
! at com.scienceminer.glutton.web.LookupServiceApplication.main(LookupServiceApplication.java:200)

Proposed solution

Add possibility to add custom headers via the Elastic field in the config or add fields specific for authentication. Would be extra nice if credentials could be loaded from env variables.

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

No branches or pull requests

1 participant