Introduction
Security helps keep important information safe from people who should not see it. It stops bad actions that can harm data or privacy.
Jump into concepts and practice - no test required
Security helps keep important information safe from people who should not see it. It stops bad actions that can harm data or privacy.
PUT /_security/role/my_role
{
"cluster": ["all"],
"indices": [
{
"names": ["my_index"],
"privileges": ["read", "write"]
}
]
}This example shows how to create a role that controls access to data.
Roles define what users can do with data in Elasticsearch.
PUT /_security/user/john
{
"password" : "strongpassword",
"roles" : ["my_role"]
}GET /_security/_authenticate
This example creates a secure index, a role that can only read it, a user with that role, and then searches the index.
PUT /my_secure_index
{
"settings": {
"index": {
"number_of_shards": 1
}
},
"mappings": {
"properties": {
"secret_info": {"type": "text"}
}
}
}
PUT /_security/role/secure_reader
{
"indices": [
{
"names": ["my_secure_index"],
"privileges": ["read"]
}
]
}
PUT /_security/user/alice
{
"password": "alicepassword",
"roles": ["secure_reader"]
}
GET /my_secure_index/_search
{
"query": {"match_all": {}}
}Always use strong passwords and limit user roles to only what they need.
Security settings help prevent unauthorized access and data leaks.
Security protects sensitive data by controlling who can see or change it.
Elasticsearch uses roles and users to manage data access.
Setting up security helps keep data safe and private.
{
"role": {
"indices": [
{
"names": ["sensitive-data"],
"privileges": ["read"]
}
]
}
}{
"role": {
"indices": [
{
"names": "sensitive-data",
"privileges": ["read", "write"]
}
]
}
}