How to grant a plugin permissions for updating indices and index templates

I created a plugin to manage index templates and index settings, however I'm seeing an error that

 action [indices:admin/template/get] is unauthorized for user [_system]

I tried adding the superuser role to the _system user, but the error message did not go away. Is there a way to have a plugin run as the elastic user or is there a way to grant the _system user the correct permissions?

_system user is immutable. For most plugins, the _xpack user is a better choice for performing internal actions.

Makes sense! How can we change the plugin to run / perform actions as the _xpack user? I couldn't find any samples anywhere.

For now you can use OriginSettingClient with TASKS_ORIGIN as shown in this piece of code:

The client will internally issue all requests with the _xpack user.

NB: This approach relies on the internals of ES code. There is no backwards compatibility guarantee at this level. The code can change in any future release and possibly break your plugin.

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