Get roles
- GET /_security/role/{name}
- GET /_security/role
Get roles in the native realm. The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The get roles API cannot retrieve roles that are defined in roles files.
Required privileges
- Cluster privileges read_security
Response
-
<string>object -
clusterunion anyOf[]required -
Values:
allcancel_taskmanagemanage_api_keymanage_behavioral_analyticsmanage_enrichmanage_esqlmanage_index_templatesmanage_inferencemanage_ingest_pipelinesmanage_logstash_pipelinesmanage_mlmanage_own_api_keymanage_pipelinemanage_reindexmanage_search_applicationmanage_search_query_rulesmanage_search_synonymsmanage_securitymanage_transformmonitormonitor_enrichmonitor_esqlmonitor_inferencemonitor_mlmonitor_reindexmonitor_transformnonepost_behavioral_analytics_eventread_pipelineread_securityread_project_routingmanage_project_routing -
indicesobject[]required -
implicitly_grantedboolean -
Set to
trueon entries that were contributed by a registeredImplicitPrivilegesProviderrather than explicitly stored on the role. Only present when the get role API is called withinclude_implicit=true. The put role API rejects this field, so clients must not echo it back on a GET-then-PUT round-trip. -
field_securityobject -
The document fields that the owners of the role have read access to.
- Reference
-
namesunion string | string[]required -
A list of indices (or index name patterns) to which the permissions in this entry apply.
-
privilegesunion anyOf[]required -
The index level privileges that owners of the role have on the specified indices.
-
Values:
allauto_configurecreatecreate_doccreate_indexcreate_viewdeletedelete_indexdelete_viewindexmaintenancemanagemanage_data_stream_lifecyclemanage_viewmonitornonereadread_view_metadataview_index_metadatawrite -
queryunion oneOf -
A search query that defines the documents the owners of the role have access to. A document within the specified indices must match this query for it to be accessible by the owners of the role.
- One of:
-
templateobject -
When you create a role, you can specify a query that defines the document level security permissions. You can optionally use Mustache templates in the role query to insert the username of the current authenticated user into the role. Like other places in Elasticsearch that support templating or scripting, you can specify inline, stored, or file-based templates and define custom parameters. You access the details for the current authenticated user through the _user parameter.
- Reference
-
sourceunion oneOf - One of:
-
paramsmap string to object -
Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
-
langunion anyOf · default: painless -
Specifies the language the script is written in.
Supported values include:
painless: Painless scripting language, purpose-built for Elasticsearch.expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.mustache: Mustache templated, used for templates.java: Expert Java API
-
Values:
painlessexpressionmustachejava
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.