How do I define security access in Elasticsearch? I have the elasticsearch-head plugin but your access doesn't require any security.
11 Answers
The plugin mentioned in this answer is no longer being actively supported.
There is no built-in access control in elasticsearch. So, you would need to setup a reverse proxy (here is a blog post how to setup nginx), use one of the 3rd party elasticsearch plugins such as https://github.com/Asquera/elasticsearch-http-basic or use the official security plugin Shield.
-
Many thanks for the hint. Any experiences with elasticsearch-http-basic? Good or bad? – Robert Reiz Dec 10 '12 at 13:29
-
A reverse proxy such as nginx will give you more security options, including SSL support. – Andrew Jan 18 '13 at 16:27
-
4Here also is the Chef cookbook for ElasticSearch that provides an easy way to install ElasticSearch with a reverse proxy using Nginx. https://github.com/elasticsearch/cookbook-elasticsearch – Tom Rogers Feb 03 '14 at 22:19
-
Some Security feature is free, starting in versions **6.8.0** and **7.1.0**. Read more: https://www.elastic.co/blog/security-for-elasticsearch-is-now-free – Aaron_ab May 28 '20 at 09:41
<shamelessPlug>
Sorry but I have serious doubts about all these plugins and proxies that only try to capture queries with sloppy regex's at HTTP level.
Will you regex all the possible ES syntax that may perform a write? How do you filter by index? How about index aliases? Multi-index queries?
The only clean way to do the access control is AFTER ElasticSearch has parsed the queries. This is exactly what Shield does after all!
I wrote a MIT licensed plugin (readonly-rest-plugin) that does exactly this.
You can match request by:
✔️ Host name, IP and IP with Netmask
✔️ Indices (wildcards supported) and index aliases are resolved
✔️ HTTP Basic Auth
It has also first class support for Kibana authentication :)
</shamelessPlug>

- 5,938
- 5
- 42
- 54
Elasticsearch now have security plugin http://www.elasticsearch.org/blog/shield-know-security-coming-soon/

- 77
- 1
- 3
-
17
-
1Now it is a reality: https://www.elastic.co/products/shield This answer is coming late, but is good for new readers. – raulsaeztapia Apr 29 '15 at 10:42
-
2
Update: This work pretty well and is (for the moste features) free and open source: https://github.com/floragunncom/search-guard
NOTE: The plugin mentioned in this article is no longer being maintained
Maybe this helps: https://github.com/salyh/elasticsearch-security-plugin
This plugin adds http/rest security functionality to Elasticsearch in kind of separate modules. Instead of Netty a embedded Tomcat 7 is used to process http/rest requests.
Currently for user based authentication and authorization Kerberos and NTLM are supported through 3rd party library waffle (only on windows servers). For UNIX servers Kerberos is supported through 3rd party library tomcatspnegoad (Works with any kerberos implementation. For authorization either Active Directory and generic LDAP is supported).
You can use this plugin also without Kerberos/NTLM but then only host based authentication is available.

- 2,095
- 1
- 17
- 31
The only preferable way to enable security in Elasticsearch is through the plugin X-Pack.
https://www.elastic.co/guide/en/x-pack/current/xpack-introduction.html
This is a multipurpose plugin and will fit well for the security purposes, as you can also use monitoring and configure the alerts and notifications as per your needs.
As it is already highly recognized, I'm sure Elasticsearch will continue with this for login.

- 6,614
- 13
- 63
- 132

- 239
- 2
- 5
If you want to use the basic authentication with Kibana3, here is my solution:
https://github.com/fangli/kibana-authentication-proxy
Support not only basicAuth ES backend, but also GoogleOAuth and BasicAuth for the client. Please give a star if it works for you, thanks.

- 1,910
- 1
- 15
- 11
-
Can you provide with some links on how to use this ?? I installed it and made the ap up, but did not find any help online about usage. – Siddharth Trikha Feb 12 '15 at 04:47
Try Shield. It has Authentication and Authorization. For now it needs a license. Won't be too long before people create similar open source plugins.

- 545
- 5
- 9
I am very novice in ElasticSearch, yet I feel that X-Pack plugin should appear here as an answer: https://www.elastic.co/guide/en/x-pack/current/index.html
It is my understanding that X-Pack is now the de-facto standard for securing ElasticSearch (and much more), including authentication.

- 143
- 1
- 10
-
1X-Pack license costs thousands of dollars per node. Elastic Cloud includes X-Pack and starts cheaper. Another option is 3rd party plugins. – Mark Toman Mar 08 '18 at 20:26
Starting from Elastic
version 6.8, Some security features became free (read: https://www.elastic.co/blog/security-for-elasticsearch-is-now-free)
Some basic steps for basic authentication
- The most basic config param to set is:
"xpack.security.enabled=true"
.
For example, if you are using docker-compose.yml
file, add the line under environment
:
elasticsearch:
image: elastic:6.8.0
environment:
- "xpack.security.enabled=true"
Next, You'll have to specify
elasic
which password the default user (which is called "elastic") should accept to authenticate. You do that withELASTIC_PASSWORD
environment variable. In our example:
elasticsearch:
image: elastic:6.8.0
environment:
- "xpack.security.enabled=true"
- "ELASTIC_PASSWORD=123456"
Now, you are set to go. When you run elastic:
docker run --rm --name elastic -p 9200:9200 -v ELASTIC_PASSWORD=123456 -v xpack.security.enabled=true elastic:6.8.0
And do: curl localhost:9200
, You'll get an error:
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}
Which is exactly what you want (no username and password give, so no access is allowed)
Very important to keep in mind:
When
Elastic
starts, it preformsBootstrap checks
(https://www.elastic.co/guide/en/elasticsearch/reference/6.8/bootstrap-checks.html).There is a difference in
Elastic
between "development" and "production" mode when preforming those checks.If
elastic
runs inproduction
mode, those configs aren't sufficient (Bootstrap check will fail and DB will not work). You also must add ssl encryption configs between nodes. Read more: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/security-settings.html

- 3,450
- 3
- 28
- 42
Regarding a specific solution to this problem, I ran across the following that is a simple implementation of a reverse proxy approach as mentioned in other answers:
https://gist.github.com/jpluscplusm/9227777
As a caveat, it seems at least some at Elasticsearch proper don't consider nginx to be the optimal solution, but I think that depends on the specifics of your authentication requirements (RBAC, user count, number of indexes, frequency of access list modifications). For some users (including myself) the first example is sufficient.
http://www.elasticsearch.org/blog/restricting-users-kibana-filtered-aliases/
If you find that your requirement specifics arent met by nginx, something like this might work: https://github.com/lukas-vlcek/node.es

- 2,027
- 2
- 17
- 24
As ElasticSearch is kinda of a database service, you probably wouldn't want it to be exposed publicly anyway.
I don't trust plugins to do that for me, so I did with a nginx proxy.
This tutorial is very very helpful:

- 3,247
- 2
- 32
- 37
-
2I get it that you don't trust them, but you can't be sure you do a *real* index isolation if you don't have access to the internal ElasticSearch parser :) That's why I wrote this: https://github.com/sscarduzio/elasticsearch-readonlyrest-plugin – sscarduzio Apr 04 '16 at 21:11