Skip to content

Commit f3e0b3a

Browse files
committed
Configuring Anonymous Authentication in OpenSearch blog post
I recently configured anonymous authentication in OpenSearch. While the documentation has some information about this, there is no guide available that list all requirements, and I had to find information in multiple places and had to look at the code to fully understand what was needed. Not great for a tasks that I assumed would be simple. More recently, people asked on Slack how to enable anonymous auth, so maybe a blog post is welcome to document the process? Signed-off-by: Romain Tartière <[email protected]>
1 parent 6e31a01 commit f3e0b3a

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
layout: post
3+
title: Configuring Anonymous Authentication in OpenSearch
4+
authors:
5+
- smortex
6+
date: 2023-12-28 16:20:00 -1000
7+
category:
8+
- technical-posts
9+
meta_keywords: anonymous, authentication, authorization
10+
meta_description: Learn how to set up OpenSearch for anonymous authentication
11+
---
12+
13+
The OpenSearch Security plugin has support multiple authentication backends.
14+
It is also possible to enable anonymous authentication to allow access to OpenSearch without prior identification.
15+
In this article, we configure anonymous authentication which is disabled by default.
16+
17+
## Enable anonymous authentication in OpenSearch
18+
19+
Anonymous access to OpenSearch is done in the Security plugin by modifying `opensearch-security/config.yml` and reloading the configuration with `securityadmin.sh`.
20+
21+
Ensure `anonymous_auth_enabled` is set to true:
22+
23+
```yaml
24+
config:
25+
# [...]
26+
dynamic:
27+
# [...]
28+
http:
29+
# [...]
30+
anonymous_auth_enabled: true
31+
```
32+
33+
Then, inject the new configuration (this will replace the configuration, exercise caution if you have changed OpenSearch configuration outside of these files):
34+
35+
```
36+
OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \
37+
-cacert /etc/opensearch/root-ca.pem \
38+
-cert /etc/opensearch/kirk.pem \
39+
-key /etc/opensearch/kirk-key.pem \
40+
-cd /etc/opensearch/opensearch-security
41+
```
42+
43+
## Enable anonymous authentication in OpenSearch-Dashboards
44+
45+
46+
Now that OpenSearch anonymous access is enabled, we must enable it in OpenSearch Dashboards by modifing `opensearch_dashboards.yml` and adding the following line:
47+
48+
```yaml
49+
opensearch_security.auth.anonymous_auth_enabled: true
50+
```
51+
52+
When done, we restart the `opensearch-dashboards` service.
53+
54+
When accessing OpenSearch Dashboards from a browser, you will automatically log in as the **opendistro_security_anonymous** user. It is possible to authenticate as another user after logging out: the usual log in screen will be presented, with a new "Log in as anonymous" button.
55+
56+
## Adjusting premissions of anonymous users
57+
58+
With the default OpenSearch configuartion, the **opendistro_security_anonymous** user has the *backend role* `opendistro_security_anonymous_backendrole` and the *role* `own_index`.
59+
This is not sufficient to access OpenSearch data and roles must be mapped to the `opendistro_security_anonymous_backendrole` *backend role* to grant access.
60+
61+
There is no one-size-fit-all configuration, so we will consider some simple use cases.
62+
63+
Configuration can be done using the OpenSearch Dashboards user interface as an administrator, or by modifing the Security plugin configuration in `opensearch-security/roles_mapping.yml` and applying changes with `securityadmin.sh`.
64+
65+
### Provide read-only access to anonymous users
66+
67+
Map the `readall` and `kibana_user` roles to the `opendistro_security_anonymous_backendrole` backend role:
68+
69+
```yaml
70+
kibana_user:
71+
reserved: false
72+
backend_roles:
73+
- "kibanauser"
74+
- "opendistro_security_anonymous_backendrole" # <--- added
75+
description: "Maps kibanauser to kibana_user"
76+
77+
readall:
78+
reserved: false
79+
backend_roles:
80+
- "readall"
81+
- "opendistro_security_anonymous_backendrole" # <--- added
82+
```
83+
84+
### Provide full access to anonymous users
85+
86+
Map the `all_access` role to the `opendistro_security_anonymous_backendrole` backend role:
87+
88+
```yaml
89+
all_access:
90+
reserved: false
91+
backend_roles:
92+
- "admin"
93+
- "opendistro_security_anonymous_backendrole" # <--- added
94+
description: "Maps admin to all_access"
95+
```
96+
97+
## Conclusion
98+
99+
In this article, we saw how to enable anonymous access to OpenSearch Dashboards.
100+
101+
In your deployment, you will likely create custom roles to give access to a subset of your data through [document-level](https://opensearch.org/docs/latest/security/access-control/document-level-security/) or [field-level](https://opensearch.org/docs/latest/security/access-control/field-level-security/) security.

0 commit comments

Comments
 (0)