Hi,
this is on ES 6.5.4 and SG 24.1.
I have the admin:password user with sg_all_access role.
I used it to create a user with role sg_all_access. When I check the user it exists:
$ curl -k -uadmin:password https://localhost:33533/_searchguard/api/user/tony_stark_1550230687
{
“tony_stark_1550230687”: {
“roles”: [
“sg_all_access”
],
“hash”: “”
}
}
I then run this query thinking Tony Stark can run anything - he is Ironman after all
$ curl -k -utony_stark_1550230687:2090203225 https://localhost:33533/index1/_search?pretty
{
“error” : {
“root_cause” : [
{
“type” : “security_exception”,
“reason” : “no permissions for [indices:data/read/search] and User [name=tony_stark_1550230687, roles=[sg_all_access], requestedTenant=null]”
}
],
“type” : “security_exception”,
“reason” : “no permissions for [indices:data/read/search] and User [name=tony_stark_1550230687, roles=[sg_all_access], requestedTenant=null]”
},
“status” : 403
}
So I’m surprised!! It’s Tony with sg_all_access and he cannot access indices:data/read/search
?!?!
Then I check the roles mapping, indeed tony stark is not listed in there:
$ curl -k -uadmin:password https://localhost:33533/_searchguard/api/rolesmapping?pretty
{
“sg_all_access” : {
“users” : [
“admin”
]
}
}
But I created Tony with sg_all_access role, is this the normal behavior?
It looks to me not … what did I miss?
The documentation does not say anything about having to patch the rolesmapping after user creation with the RESP API:
Anyways, now I PATCH the rolesmapping:
curl -X PATCH -k -uadmin:password https://localhost:33533/_searchguard/api/rolesmapping/sg_all_access -H “Content-type: application/json” -d ’
[{“op”: “replace”, “path”: “/users”, “value”: [“admin”, “tony_stark_1550230687"]}]’
Check the rolesmapping and this time Tony is there:
$ curl -k -uadmin:password https://localhost:33533/_searchguard/api/rolesmapping?pretty
{
“sg_all_access” : {
“users” : [
“admin”,
“tony_stark_1550230687”
]
}}
And sure enough Tony Stark can now search indices:
$ curl -k -utony_stark_1550230687:2090203225 https://localhost:33533/index1/_search?pretty
{
“took” : 5,
“timed_out” : false,
“_shards” : {
“total” : 5,
“successful” : 5,
“skipped” : 0,
“failed” : 0
},
“hits” : {
“total” : 2,
“max_score” : 1.0,
“hits” : [
{
“_index” : “index1”,
“_type” : “_doc”,
“_id” : “0”,
“_score” : 1.0,
“_source” : {
“id” : 0
}
},
{
“_index” : “index1”,
“_type” : “_doc”,
“_id” : “1”,
“_score” : 1.0,
“_source” : {
“id” : 1
}
}
]
}
}
PS:
There is also an error in the doc concerning the return message after the creation of a user.
// SG doc says one thing and in fact the API returns something else.
// Internal users REST API endpoints | Elasticsearch Security | Search Guard
// This should be the return message according to the doc:
// withJsonPath(“message”, equalTo(“User $userName created”.toString())),
// This is what SG 24.1 in fact returns:
withJsonPath(“message”, equalTo(“‘$userName’ created.”.toString())),