Closed jmreicha closed 4 years ago
@jmreicha if you haven't already, can you install the Debug Bar and Debug Bar ElasticPress plugins and see what sort of results you're getting from searches?
My suspicion is perhaps the header is getting filtered into some, but not all, requests. For example, if the filter is only running on indexing time, your searches would fail. The Debug Bar ElasticPress plugin's output includes the Headers that are sent, so this will give you exactly the debugging info you need.
@brandwaffle I might not be looking in the right place but the headers all appear to be the same, including successful requests.
array(1) {
["Content-Type"]=>
string(16) "application/json"
}
Hi @jmreicha , I know this has been here for a while now but did you had the chance to fix the problem? If so, can you please share the solution? That way we can keep it for other users with the same problem.
If you didn't fix it, do you mind sharing the code you're using to add the header?
Thanks!
If I remember, we basically forced it to add a x-api-key
header to all requests and then check if the header was there. Unfortunately I can't seem to find the code that does this.n
Theoretically, a code like this would add a header to all requests:
add_filter(
'ep_format_request_headers',
function( $headers ) {
$headers['x-api-key'] = 'API_KEY';
return $headers;
}
);
Are you able to connect to your ES server through a program like https://www.postman.com/
, for example? That can help to pin point the problem.
Yes, I think the above example is almost exactly what we ended up doing.
On Tue, Jun 9, 2020 at 9:11 AM Felipe Elia notifications@github.com wrote:
Theoretically, a code like this would add a header to all requests:
add_filter( 'ep_format_request_headers', function( $headers ) { $headers['x-api-key'] = 'API_KEY'; return $headers; } );
Are you able to connect to your ES server through a program like https://www.postman.com/, for example? That can help to pin point the problem.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/10up/ElasticPress/issues/1700#issuecomment-641323576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH5V6R6IJ3YLBS76XR44ODRVY7IZANCNFSM4LHJVYZQ .
Nice, @jmreicha, thanks. I'll go ahead and close this issue, feel free to reopen it if you need.
Have you searched for similar issues before submitting this one?
Yes
Is this a bug, question or feature request?
Question
Describe the issue you encountered:
Attempting to connect ElasticPress to a self hosted ElasticSearch server via AWS Api-Gateway using an API key for authentication. Using some custom code to add the
x-api-key
header to the request.Some requests seem to return 200 but others don't. Below is an example of the errors I am seeing when I have auth turned on.
If the API key is disabled everything works again as expected. I should also mention these curl commands work from the command line when the
x-api-key
is insterted into the headers.Current WordPress version?
5.3.2
Current ElasticPress version?
3.3
Current Elasticsearch version?
6.4
Where do you host your Elasticsearch server?
AWS - Using an API Gateway to add authentication with an API key and the proxying the request to the AWS ElasticSearch service through a Lambda.
Other plugins installed (WooCommerce, Simple Redirect Manager, etc..)?
Steps to reproduce:
NA
Screenshots, if needed:
Settings seem to be greyed out when the API key is enabled and can't update any config.