Skip to content

Instantly share code, notes, and snippets.

@jtibshirani
Last active May 15, 2018 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtibshirani/ff8ebcd235dc8be36ecd84543b29525d to your computer and use it in GitHub Desktop.
Save jtibshirani/ff8ebcd235dc8be36ecd84543b29525d to your computer and use it in GitHub Desktop.
Authorization failure when indexing document with new mappings to alias.
# Create an index called 'test', and an alias to it called 'test_alias'.
curl -XPUT -u elastic:<admin_password> http://localhost:9200/test -H 'Content-Type: application/json'
curl -XPOST -u elastic:<admin_password> http://localhost:9200/_aliases -H 'Content-Type: application/json' -d '{
"actions" : [
{ "add" : { "index" : "test", "alias" : "test_alias" } }
]
}'
# Set ip a user called 'test_user' that is allowed to write to 'test_alias'.
curl -XPOST -u elastic:<admin_password> http://localhost:9200/_xpack/security/role/test_role -H 'Content-Type: application/json' -d '{
"cluster": [
"monitor"
],
"indices": [
{
"names": [ "test_alias" ],
"privileges": [ "write" ]
}
]
}'
curl -XPOST -u elastic:1bMvr5d1rtChtrvQmQdd http://localhost:9200/_xpack/security/user/test_user -H 'Content-Type: application/json' -d '{
"password" : "changeme",
"roles" : [ "test_role" ]
}'
# Attempt to index a document with new mappings, and the below error occurs.
curl -XPOST -u test_user:changeme -H 'Content-Type: application/json' -XPOST localhost:9200/test_alias/doc/1?pretty -d '{
"timestamp": "2018-05-11T12:00:00.000Z"
}'
> {
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "action [indices:admin/mapping/put] is unauthorized for user [test_user]"
}
],
"type" : "security_exception",
"reason" : "action [indices:admin/mapping/put] is unauthorized for user [test_user]"
},
"status" : 403
}
# Put mappings can successfully be called directly.
curl -u test_user:changeme -H 'Content-Type: application/json' -XPUT localhost:9200/test_alias/doc/_mapping -d '{
"properties": {
"timestamp":{"type":"date"}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment