To enforce data confidentiality and maintain user accessibility with Elasticsearch, we need to know how to create custom roles and users. In this hands-on lab, we go through the following tasks on a single-node Elasticsearch cluster, using either Kibana or `curl` on the command line:
* Create custom roles
* Create users
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create the sample_read Role
Use the Kibana console tool to execute the following:
POST _security/role/sample_read { "indices": [ { "names": [ "sample-*" ], "privileges": [ "read" ] } ] }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/role/sample_read?pretty" -H 'Content-Type: application/json' -d'{"indices":[{"names":["sample-*"],"privileges":["read"]}]}'
- Create the sample_write Role
Use the Kibana console tool to execute the following:
POST _security/role/sample_write { "indices": [ { "names": [ "sample-*" ], "privileges": [ "read", "write" ] } ] }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/role/sample_write?pretty" -H 'Content-Type: application/json' -d'{"indices":[{"names":["sample-*"],"privileges":["read","write"]}]}'
- Create the sample_monitor Role
Use the Kibana console tool to execute the following:
POST _security/role/sample_monitor { "indices": [ { "names": [ "sample-*" ], "privileges": [ "read", "monitor" ] } ] }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/role/sample_monitor?pretty" -H 'Content-Type: application/json' -d'{"indices":[{"names":["sample-*"],"privileges":["read","monitor"]}]}'
- Create the john User
Use the Kibana console tool to execute the following:
POST _security/user/john { "roles": [ "kibana_user", "sample_read" ], "full_name": "John Doe", "email": "john@company.com", "password": "john_123" }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/user/john?pretty" -H 'Content-Type: application/json' -d'{"roles":["kibana_user","sample_read"],"full_name":"John Doe","email":"john@company.com","password":"john_123"}'
- Create the jane User
Use the Kibana console tool to execute the following:
POST _security/user/jane { "roles": [ "kibana_user", "sample_write" ], "full_name": "Jane Doe", "email": "jane@company.com", "password": "jane_456" }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/user/jane?pretty" -H 'Content-Type: application/json' -d'{"roles":["kibana_user","sample_write"],"full_name":"Jane Doe","email":"jane@company.com","password":"jane_456"}'
- Create the noc User
Use the Kibana console tool to execute the following:
POST _security/user/noc { "roles": [ "kibana_user", "sample_monitor", "monitoring_user" ], "full_name": "Network Operations Center", "email": "noc@company.com", "password": "noc_789" }
Or, use command-line
curl
on any one of the nodes via ssh:curl -k -u elastic:la_elastic_409 -XPOST "http://localhost:9200/_security/user/noc?pretty" -H 'Content-Type: application/json' -d'{"roles":["kibana_user","sample_monitor","monitoring_user"],"full_name":"Network Operations Center","email":"noc@company.com","password":"noc_789"}'