Closed serlo89 closed 1 year ago
I found that the authentication was not set correctly and caused the Error 401 Unauthorized. Fixing the problem made the query works but impersonation didn't work yet.
To impersonate i had to set the following code:
$clientBuilder->setHttpClientOptions(['headers' => ['es-security-runas-user' => 'userToBeImpersonated']]);
and remove the 'client' parameter which is useless.
Cannot add header 'es-security-runas-user' to impersonate another user
I am trying to upgrade a PHP website from Elastic 7 to Elastic 8. This website use impersonation and this is not working if I upgrade to ES-PHP 8.
In ES-PHP 7 i used to build the query in this way:
I checked the breaking changes from ES7 to ES8 and i found the following:
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/breaking_changes.html
So, how can I now add the header to impersonate another user? I'm sure that every setting in Elasticsearch is correct because if i send a request impersonating a user via curl or postman it works, but using the website i have the following Exception:
So, the custom header was not sent to the request. Thanks