I’m trying to add a user to a role mapping using the API.
I’m probably mis-understanding the PATCH method, so maybe someone can explain what’s going on here:
☠ ES GET _searchguard/api/rolesmapping/sg_role_test
HTTP/1.1 200 OK
content-length: 134
content-type: application/json; charset=UTF-8
{
"sg_role_test": {
"and_backend_roles": [],
"backend_roles": [],
"description": "Migrated from v6",
"hosts": [],
"users": [
"one",
"two",
"three"
]
}
}
☠ ES PATCH _searchguard/api/rolesmapping/sg_role_test <<< '[{"op":"add","path":"/users","value":["four"]}]'
HTTP/1.1 200 OK
content-length: 51
content-type: application/json; charset=UTF-8
{
"message": "'sg_role_test' updated.",
"status": "OK"
}
☠ ES GET _searchguard/api/rolesmapping/sg_role_test
HTTP/1.1 200 OK
content-length: 121
content-type: application/json; charset=UTF-8
{
"sg_role_test": {
"and_backend_roles": [],
"backend_roles": [],
"description": "Migrated from v6",
"hosts": [],
"users": [
"four"
]
}
}
I was expecting that the user four be appended to the existing array, hence producing the users list ["one", "two", "three", "four"].
This is on a test cluster using search-guard-flx 1.0.0-beta-2-es-7.10.2.
That refers to the last element of the array. In order to add to an array, you have to reference an element inside the array. Using 0 would insert after the first, using - inserts after the last.
Ah !
I might be wrong but this - isn’t documented neither on the rfc nor on the sg documentation.
In any case, I think it would be a good idea to add it to your doc.