Impersonate using NodeClient

  1. Can I impersonate using NodeClient? I am writing a plugin and I want to impersonate an user. I tried to do below and it didn’t work.
public class MyPluginAction extends BaseRestHandler {
 ......
@Override
 protected final BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client)  {
    ThreadContext.StoredContext ctx = client.threadPool().getThreadContext().stashContext();  
    client.threadPool().getThreadContext().putHeader("sg_impersonate_as", "bob");
    //make a search request...
  .....
  .....
}   
  1. Do you have an api to give a user permission to impersonate as another user ?

Do you develop a Kibana plugin?

You can query SearchGuard API as another user, for example

curl -u admin:password  \
  -H "sg_impersonate_as: user_1"  \
  -XGET https://example.com:9200/_searchguard/authinfo?pretty

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.