Allow kibana_system to create and invalidate API keys on behalf of other users#53824
Merged
peterschretlen merged 2 commits intoelastic:masterfrom Mar 23, 2020
Merged
Conversation
Collaborator
|
Pinging @elastic/es-security (:Security/Authorization) |
Author
|
Related PR on Kibana side: elastic/kibana#60423 |
Author
|
Tested locally to confirm the roles are added and working as expected.
$ curl -k -s -u elastic:changeme https://localhost:9200/_security/role/kibana_system | jq .kibana_system.cluster
[
"monitor",
"manage_index_templates",
"cluster:admin/xpack/monitoring/bulk",
"manage_saml",
"manage_token",
"manage_oidc",
"cluster:admin/xpack/security/api_key/invalidate", <---- added
"grant_api_key", <---- added
"cluster:admin/xpack/security/privilege/builtin/get",
"delegate_pki",
"cluster:admin/ilm/get",
"cluster:admin/ilm/put",
"cluster:admin/analyze"
]
$ curl -k -s -u elastic:changeme https://localhost:9200/_security/user/kibana | jq -c .kibana.roles
["kibana_system"]
# create key for elastic user
$ curl -k -s -u elastic:changeme -H content-type:application/json -d '{ "name":"my-key" }' https://localhost:9200/_security/api_key | jq .
{
"id": "IEFY9HABM4_s1PGvY_DW",
"name": "my-key",
"api_key": "2VVEhxpRSwqq3PV3clHGZg"
}
# kibana user invalidates key
$ curl -k -s -u kibana:changeme -H content-type:application/json -XDELETE -d '{ "name":"my-key" }' https://localhost:9200/_security/api_key | jq .
{
"invalidated_api_keys": [
"IEFY9HABM4_s1PGvY_DW"
],
"previously_invalidated_api_keys": [],
"error_count": 0
}
# kibana grants key for elastic user
$ curl -k -s -u kibana:changeme -H content-type:application/json -d '{ "grant_type":"password", "username":"elastic", "password":"changeme" }' https://localhost:9200/_security/api_key/grant | jq .
{
"id": "HEFi9HABM4_s1PGvv_GA",
"name": null,
"api_key": "1XI-g2IWRseli9E3G3yazg"
}
# list keys for elastic user
$ curl -k -s -u elastic:changeme https://localhost:9200/_security/api_key?username=elastic | jq .
{
"api_keys": [
{
"id": "HEFi9HABM4_s1PGvv_GA",
"name": null,
"creation": 1584648077171,
"invalidated": false,
"username": "elastic",
"realm": "reserved"
}
]
} |
legrego
reviewed
Mar 20, 2020
Member
legrego
left a comment
There was a problem hiding this comment.
Thanks Peter! The additional privileges look good to me. Can we also update the existing test to ensure the kibana_system role can perform these actions?
Contributor
|
Thanks @peterschretlen I was off sick at the end of last week, and was just about to pick this up when I saw you had done it. |
peterschretlen
pushed a commit
to peterschretlen/elasticsearch
that referenced
this pull request
Mar 23, 2020
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds the following privileges to the
kibana_systemrole:grant_api_keyrecently added in Add "grant_api_key" cluster privilege #53527api_key/invalidateThis is to support alerting on Kibana, which uses API keys to run scheduled background alert checks on a user's behalf as described in #48716 (comment)
Related: elastic/kibana#49398