That is exactly, what I was looking for! Sorry, I didn't realized it has been documented already!
So, I'm trying the template role query right now, but I'm not getting results:
GET /_xpack/security/role/searchgrp
{
"searchgrp": {
"cluster": [],
"indices": [
{
"names": [
"topbeat-*",
"test",
".kibana"
],
"privileges": [
"read",
"view_index_metadata"
],
"field_security": {
"grant": [
"*"
]
},
"query": "{ \"match\" : { \"acl_allow\" : \"{{_user.username}}\" }}"
}
],
"run_as": [],
"metadata": {}
}
}
Query:
GET http://localhost:9200/test/_search
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
Logs:
[2017-01-18T14:27:26,784][DEBUG][o.e.x.s.a.a.ActiveDirectoryRealm] [host] authenticated user [search], with roles [[searchgrp, Domain Users, Users]]
[2017-01-18T14:27:26,790] [transport] [access_granted] origin_type=[rest], origin_address=[127.0.0.1], principal=[search], action=[indices:data/read/search], indices=[test], request=[SearchRequest]
[2017-01-18T14:27:26,791] [transport] [access_granted] origin_type=[rest], origin_address=[127.0.0.1], principal=[search], action=[indices:data/read/search[phase/query+fetch]], indices=[test], request=[ShardSearchTransportRequest]
If I replace the template {{_user.username}}
by the real user name ("search") in the role query, then the "secured" documents get found.
Am I missing something?
Thank you!
Update:
Index mapping:
PUT test
{
"mappings": {
"t": {
"properties": {
"acl_allow": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
corresponding superuser query:
GET test/_search
{
"query": {
"match": {
"acl_allow": "search"
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.2039728,
"hits": [
{
"_index": "test",
"_type": "t",
"_id": "1",
"_score": 1.2039728,
"_source": {
"title": "document 1",
"acl_allow": [
"search"
]
}
}
]
}
}
Update II
Upgraded the ES instance from 5.0.0 to 5.1.2 - no improvements, can't make the "mustache" template working.
Any suggestions would be highly appreciated!
Thanks!