Reputation: 494
I have few index in my cluster
index_2019-01-01
index_2019-01-02
index_2019-01-03
index_2019-01-04
index_2019-01-05
index_2019-01-06
There are two user USER1 & USER2
USER1 has full right to this index pattern.
I want to provide access rigths to USER2 for first three index only.
How can I achieve this in ELK
Elastic version 7.2
Upvotes: 2
Views: 2847
Reputation: 107
I know you're asking about Elastic v7.2, but I stumbled upon this question and I'm using ES v8.4.1. In case someone else ends up here from a Google search, I want to say that it's very much possible to do what OP wants.
I'll assume that the built-in user elastic
has the password '123456', which you can set via ELASTIC_PASSWORD: 123456
in docker-compose.yml
if you're using Docker (link).
If you're using Docker, exec into the elasticsearch Docker container via docker exec -it elasticsearch bash
. Here are the steps to enable index-level access:
curl -X POST "localhost:9200/_security/role/regular?pretty" -H 'Content-Type: application/json' -d'
{
"cluster": ["all"],
"indices": [
{
"names": [ "index_2019-01-01", "index_2019-01-02", "index_2019-01-03"],
"privileges": ["all"]
}
]
}
' -u elastic:123456
curl -X POST "localhost:9200/_security/user/john?pretty" -H 'Content-Type: application/json' -d'
{
"password" : "123456",
"roles" : [ "regular" ],
"full_name" : "John John",
"email" : "[email protected]",
"metadata" : {
"intelligence" : 7
}
}
' -u elastic:123456
Now try fetching all the docs from any of the indexes that john
has access to (you should see all the docs):
curl "localhost:9200/index_2019-01-01/_search?pretty=true" -u john:123456
Also, try fetching the docs from an index that john
doesn't have access to (you should receive a 403 HTTP status in the response):
curl "localhost:9200/index_2019-01-04/_search?pretty=true" -u john:123456
Upvotes: 0
Reputation: 3667
This feature (index level security) is not possible with the basic license of elasticsearch.
But there are several other ways to archieve it with more or less invest of money and/or time:
Have fun!
Upvotes: 1