BodyRequired
- application
array[object] - cluster
array[string] A list of the cluster privileges that you want to check.
- index
array[object]
POST /_security/user/_has_privileges
Console
GET /_security/user/_has_privileges
{
"cluster": [ "monitor", "manage" ],
"index" : [
{
"names": [ "suppliers", "products" ],
"privileges": [ "read" ]
},
{
"names": [ "inventory" ],
"privileges" : [ "read", "write" ]
}
],
"application": [
{
"application": "inventory_manager",
"privileges" : [ "read", "data:write/inventory" ],
"resources" : [ "product/1852563" ]
}
]
}
resp = client.security.has_privileges(
cluster=[
"monitor",
"manage"
],
index=[
{
"names": [
"suppliers",
"products"
],
"privileges": [
"read"
]
},
{
"names": [
"inventory"
],
"privileges": [
"read",
"write"
]
}
],
application=[
{
"application": "inventory_manager",
"privileges": [
"read",
"data:write/inventory"
],
"resources": [
"product/1852563"
]
}
],
)
const response = await client.security.hasPrivileges({
cluster: ["monitor", "manage"],
index: [
{
names: ["suppliers", "products"],
privileges: ["read"],
},
{
names: ["inventory"],
privileges: ["read", "write"],
},
],
application: [
{
application: "inventory_manager",
privileges: ["read", "data:write/inventory"],
resources: ["product/1852563"],
},
],
});
response = client.security.has_privileges(
body: {
"cluster": [
"monitor",
"manage"
],
"index": [
{
"names": [
"suppliers",
"products"
],
"privileges": [
"read"
]
},
{
"names": [
"inventory"
],
"privileges": [
"read",
"write"
]
}
],
"application": [
{
"application": "inventory_manager",
"privileges": [
"read",
"data:write/inventory"
],
"resources": [
"product/1852563"
]
}
]
}
)
$resp = $client->security()->hasPrivileges([
"body" => [
"cluster" => array(
"monitor",
"manage",
),
"index" => array(
[
"names" => array(
"suppliers",
"products",
),
"privileges" => array(
"read",
),
],
[
"names" => array(
"inventory",
),
"privileges" => array(
"read",
"write",
),
],
),
"application" => array(
[
"application" => "inventory_manager",
"privileges" => array(
"read",
"data:write/inventory",
),
"resources" => array(
"product/1852563",
),
],
),
],
]);
curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"cluster":["monitor","manage"],"index":[{"names":["suppliers","products"],"privileges":["read"]},{"names":["inventory"],"privileges":["read","write"]}],"application":[{"application":"inventory_manager","privileges":["read","data:write/inventory"],"resources":["product/1852563"]}]}' "$ELASTICSEARCH_URL/_security/user/_has_privileges"
Request example
Run `GET /_security/user/_has_privileges` to check whether the current user has a specific set of cluster, index, and application privileges.
{
"cluster": [ "monitor", "manage" ],
"index" : [
{
"names": [ "suppliers", "products" ],
"privileges": [ "read" ]
},
{
"names": [ "inventory" ],
"privileges" : [ "read", "write" ]
}
],
"application": [
{
"application": "inventory_manager",
"privileges" : [ "read", "data:write/inventory" ],
"resources" : [ "product/1852563" ]
}
]
}
Response examples (200)
A successful response from `GET /_security/user/_has_privileges`, which lists the privileges for the `rdeniro` user.
{
"username": "rdeniro",
"has_all_requested" : false,
"cluster" : {
"monitor" : true,
"manage" : false
},
"index" : {
"suppliers" : {
"read" : true
},
"products" : {
"read" : true
},
"inventory" : {
"read" : true,
"write" : false
}
},
"application" : {
"inventory_manager" : {
"product/1852563" : {
"read": false,
"data:write/inventory": false
}
}
}
}