Submitting requests on behalf of other users
The Elasticsearch security features support a permission that enables an authenticated user to submit requests on behalf of other users. If your application already authenticates users, you can use the run as mechanism to restrict data access according to Elasticsearch permissions without having to re-authenticate each user.
To "run as" (impersonate) another user, that user must exist in a realm that supports the run as mechanism. Both the internal native and file realms support this out of the box. The LDAP realm must be configured to run in user search mode. The Active Directory realm must be configured with a bind_dn and secure_bind_password to support run as. The Kerberos, OpenID Connect, PKI, and SAML realms do not support run as.
To submit requests on behalf of other users, you need to have the run_as permission. For example, the following role grants permission to submit request on behalf of jacknich or redeniro:
{
"run_as" : [ "jacknich", "rdeniro" ]
} To submit a request as another user, you specify the user in the es-security-runas-user request header. For example:
curl -H "es-security-runas-user: jacknich" -u es_admin -XGET 'http://localhost:9200/'
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/run-as-privilege.html