-
Notifications
You must be signed in to change notification settings - Fork 45
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
Can't authenticate as AWS Elasticsearch Service does not return WWW-Authenticate header #49
Comments
Wow, I expected AWS ES to produce a "nicer response". I'll look into it. I the meantime - since you've mentioned fine grained access control - make sure that you can cURL following endpoints:
|
Do you use IAM or internal database? I'd assume internal database since you'd like to supply credentials, but just wanted to make sure before I spend cash to reproduce it :) |
Hi @rfoltyns, thanks for looking into this. Unfortunately, this was done in our organizational non-prod ES instance. I tried executing below cURL command and it worked. Also I tried working with ECE trial version installed in an EC2, in that case it worked because ECE supports x-pack. |
Could you also try the cURL below (index document with Bulk API)? Make sure that the index does not exist before running the cURL. Let's verify that the user has following permissions in ES:
curl -X POST '$AWS_ES_URL/_bulk' \
-H 'Authorization: Basic <user:pass to base64>' \
-H 'Content-Type: application/json' \
--data "
{\"index\":{\"_index\":\"customerindex\",\"_type\":\"_doc\"}}
{\"timestamp\":1591030115187,\"loggerName\":\"test-logger\"}
" You may also need to create an index template for your index. It will be needed so you can properly create an index pattern in Kibana to make logs visible. You'll need |
I've found the issue. AWS Elasticsearch Service does not send back the In my case, Open Distro config looks correct (
However, update is not possible.
|
Hi @rfoltyns, I executed below command as you said, and it worked. particular record was added to the index with 201 response.
I tried to add a record to an index using below cURL, and it also worked.
Furthermore I think, there may be some configuration from AWS ES instance to make it work. I am studying this article which explains how Basic auth is handled with fine-grained access control. I'll update if I found anything. Thanks. |
Requests suceeded, that's great! It means that auth works (sort of). Try to remove the Can you raise an issue with AWS Support to address this? I can't do it with my basic subscription, but maybe your company can. |
Since this hc-logappender uses Apache:httpcomponents-asyncclient, I implemented below sample java app to send a record to our authenticated ES instance. It was successful with 201 response. (I used httpasyncclient : 4.0.1)
Here this application uses
And this failed with |
Nice one! Notice that it works once you provide the header explicitly (of course! just like the cURL request). Credentials provider is used only during challenges, so everything works as expected. However, HC module doesn't support explicit auth headers config. IMHO it's not an issue - it's just based on auth challenges. It works perfectly with Elasticsearch with auth. Open Distro should produce this header as configured (according to the docs), but it doesn't - the issue is there. You can extend |
Sure, I'll try that approach and let you know. |
I've checked OpenDistro 1.4.0 (7.4.2 equivalent, "latest" AWS ES) and 1.8.0 locally - both are responding with If only AWS allowed to raise issues with basic subscription.. |
Sure, I'll raise this issue to AWS. |
I raised a support case and got below response.
As explained here, I will try with integrating Cognito. |
Can you use IAM? I think it can be used for traffic from EC2. Is your instance accessed from outside of AWS? |
Yeah, I think they misread it. Cognito is used for SSO. Using an IAM won't work as data is ingested through many sources. |
Description
I used an AWS Elasticsearch instance (doesn't support x-pack) with fine grained access control. Used master username and password for basic credentials. I got below exception.
2020-05-31 23:52:57,142 I/O dispatcher 1 WARN Unrecognized token 'Unauthorized': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (org.appenders.log4j2.elasticsearch.hc.ItemSourceContentInputStream); line: 1, column: 13] com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Unauthorized': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: (org.appenders.log4j2.elasticsearch.hc.ItemSourceContentInputStream); line: 1, column: 13] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1840) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:722) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidToken(UTF8StreamJsonParser.java:3556) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2651) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:856) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:753) at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:357) at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1704) at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1228) at org.appenders.log4j2.elasticsearch.hc.HCHttp$1.deserializeResponse(HCHttp.java:190) at org.appenders.log4j2.elasticsearch.hc.HCHttp$1.deserializeResponse(HCHttp.java:158) at org.appenders.log4j2.elasticsearch.hc.HCResultCallback.completed(HCResultCallback.java:55) at org.appenders.log4j2.elasticsearch.hc.HCResultCallback.completed(HCResultCallback.java:38) at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:122) at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:181) at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:448) at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:338) at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265) at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81) at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39) at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121) at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162) at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337) at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591) at java.lang.Thread.run(Thread.java:748)
Can you please give me a solution ?
Configuration
<Elasticsearch name="elasticsearch"> <IndexName indexName="customerdata"/> <JacksonJsonLayout> <PooledItemSourceFactory poolName="itemPool" itemSizeInBytes="1024" initialPoolSize="3000"/> </JacksonJsonLayout> <AsyncBatchDelivery batchSize="1000" deliveryInterval="10000" > <HCHttp serverUris="${env:AWS_ES_URL}"> <Security> <BasicCredentials username="USERNAME" password="PASSWORD" /> </Security> <PooledItemSourceFactory poolName="batchPool" itemSizeInBytes="1024000" initialPoolSize="3"/> </HCHttp> </AsyncBatchDelivery> </Elasticsearch>
Runtime (please complete the following information):
The text was updated successfully, but these errors were encountered: