How to Configure Elasticsearch Grant Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up elasticsearch grant permissions, you create roles with specific cluster and index rules. Then you map those roles to users or keys in your security settings. Many engineering teams start by sharing one broad admin user for local apps and tests. Over time, that shared user gets copied into production scripts and human workstations. When permissions are too wide, one mistake can wipe out an entire production index. A single bad query can also expose private customer records to the wrong

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To set up elasticsearch grant permissions, you create roles with specific cluster and index rules. Then you map those roles to users or keys in your security settings. Many engineering teams start by sharing one broad admin user for local apps and tests. Over time, that shared user gets copied into production scripts and human workstations. When permissions are too wide, one mistake can wipe out an entire production index. A single bad query can also expose private customer records to the wrong person.

How elasticsearch grant permissions work

The native security model uses role-based rules to control who can read or write data. Every request hits the cluster with a user identity or an API key attached. The security engine checks the roles linked to that user before running the action. A role holds two main types of rights: cluster rules and index rules.

Cluster rules control big actions across the whole system. These include checking cluster health, managing snapshots, or changing node settings. Index rules control what a user can do inside specific data sets. You can name exact indices or use simple wildcards to match a group of logs. Inside an index rule, you pick actions like read, write, delete, or manage.

You can also limit rights down to specific fields or documents inside an index. Field rules let you hide certain fields from a role during a search request. Document rules use a query filter so users only get rows that match their team. Once you build a role, you bind it to local users or external groups. When a team member logs in through an identity provider, the cluster checks their group. It then applies the matching role rules to every search or write they send.

Why role mappings need more than static setup

Setting up roles for apps works well because app traffic stays predictable. An app reads from one index and writes to another index all day long. Human engineers are very different when they need to fix a live bug. An on-call engineer might need read rights today and write rights for ten minutes tomorrow. Because creating new roles takes time, teams often put engineers into broad admin groups.

Static roles also decide who can log in, not what a specific query does. If a developer has read rights on a customer index, they can pull every record. Native field rules require you to maintain complex role definitions for every single index change. If a new index appears without a field rule, raw emails and phone numbers return. Static permissions also fail to pause risky bulk delete requests before they run. Teams end up choosing between slow ticket queues or wide open cluster roles.

Elasticsearch Security + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing day-to-day search rules for teams

To keep your cluster safe, start by splitting human roles from machine roles right away. Give each background service its own dedicated API key scoped to exact index names. Never let a human engineer use a service key to run manual fixes from home.

For human users, keep default roles limited to read-only rules on non-sensitive indices. Review your role bindings every month to remove old groups and unused keys. When sensitive indices hold card numbers or national IDs, avoid giving out raw read roles. Instead, look for ways to rewrite matched fields in results before they reach the screen. Good audit logs are also vital when you manage many search clusters. Make sure you record who ran each query and when they ran it.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

What is the difference between cluster rules and index rules?

Cluster rules control system-wide tasks like checking node health or managing backups. Index rules control data tasks like reading, writing, or deleting documents in specific indices.

How do API keys handle permissions in a search cluster?

An API key carries its own set of role rules when you create it. Importantly, a key cannot hold more permissions than the user who created it.

Can one user hold multiple roles at the same time?

Yes, a user can map to several roles at once through their group memberships. The cluster combines all granted rules together when checking what that user can do.

The query runs. The emails stay hidden.