Support optional anonymous authentication#114
Support optional anonymous authentication#114kylehounslow merged 4 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #114 +/- ##
=======================================
Coverage 18.51% 18.51%
=======================================
Files 3 3
Lines 54 54
Branches 19 19
=======================================
Hits 10 10
Misses 44 44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
PR #114 Review: Support optional anonymous authenticationOverall: This is a well-structured, well-documented feature. The single-toggle design via 🔴 Must-fix (blocking)1. This is the biggest issue. The Dashboards template sets This should be conditional — either use a second 2. The PR docs say "Any saved objects created by anonymous users are preserved and remain accessible to authenticated users after disabling anonymous auth." This is contradicted by the requirement to use
The current docs are misleading. At minimum, fix the documentation to remove the claim about preserved saved objects. 3. The comment says "Reserved/static roles are built into the security plugin and remain available." This is true, but mounting a custom 🟡 Should-fix (non-blocking but important)4. The placeholder if [ "${OPENSEARCH_ANONYMOUS_AUTH}" != "true" ]; then export OPENSEARCH_ANONYMOUS_AUTH=false; fi5. Duplicate There's a duplicate 6. In 7. The comment explains why, but this is broader than necessary. For a dev quickstart it's acceptable, but worth noting that in any multi-tenant scenario this would be a significant privilege escalation. Consider scoping to just the global tenant if possible. 🟢 Nits / suggestions
SummaryThe architecture is sound — single env var toggle, template-based injection, least-privilege role design with a well-reasoned exception for Dashboards system indices. The main issues are: (1) the unconditional |
| # but cannot delete existing saved objects or perform admin operations | ||
| # Modify access is required — Dashboards persists UI settings via update/bulk writes on page load | ||
| # Set OPENSEARCH_ANONYMOUS_AUTH=true in .env to enable | ||
| opensearch_security.auth.anonymous_auth_enabled: OPENSEARCH_ANONYMOUS_AUTH |
There was a problem hiding this comment.
nit: rename to OPENSEARCH_ANONYMOUS_AUTH_ENABLED to better match config name
There was a problem hiding this comment.
lol, claude suggested it from that to this due to how other values were named. Will change it back.
docker-compose/README.md
Outdated
| By default, users must log in to access OpenSearch Dashboards. To skip the login page (useful for demos or workshops), enable anonymous authentication in `.env`: | ||
|
|
||
| ```env | ||
| OPENSEARCH_ANONYMOUS_AUTH=true |
There was a problem hiding this comment.
same nit re: name above. apply across all files
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
| payload = { | ||
| "name": datasource_name, | ||
| "allowedRoles": [], | ||
| "allowedRoles": ["all_access", "opendistro_security_anonymous_role"] if ANONYMOUS_AUTH_ENABLED else ["all_access"], |
There was a problem hiding this comment.
should this be if OPENSEARCH_ANONYMOUS_AUTH_ENABLED?
There was a problem hiding this comment.
nvm I see this set at L18, please disregard
Reverts: - 3155afe fix: rename OPENSEARCH_ANONYMOUS_AUTH to OPENSEARCH_ANONYMOUS_AUTH_ENABLED in .env (opensearch-project#115) - b5aeed7 feat: Support optional anonymous authentication (opensearch-project#114) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reverts: - 3155afe fix: rename OPENSEARCH_ANONYMOUS_AUTH to OPENSEARCH_ANONYMOUS_AUTH_ENABLED in .env (opensearch-project#115) - b5aeed7 feat: Support optional anonymous authentication (opensearch-project#114) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
Summary
Adds optional anonymous authentication for OpenSearch and OpenSearch Dashboards, controlled by a single
.envtoggle (OPENSEARCH_ANONYMOUS_AUTH). This makes it easy to skip the login page for demos, workshops, or shared development environments..envvariable:OPENSEARCH_ANONYMOUS_AUTH=false(default off, set totrueto enable)config.template.yml,roles.yml, androles_mapping.ymldefine the anonymous role with read access to all indices and limited write access to Dashboards system indices (needed for UI settings persistence)anonymous_auth_enabledand disablesavedObjects.permission.enabledso anonymous users can access workspaces created by the init scriptdefaultWorkspaceso all users (including anonymous) land directly in the Observability Stack workspace; adds anonymous role to Prometheus datasourceallowedRolesHow it works
OPENSEARCH_ANONYMOUS_AUTHis read from.envand injected viasedat container startup into two templates:config.template.yml→ OpenSearch security plugin configopensearch_dashboards.template.yml→ Dashboards configroles.ymlgrants anonymous users read access everywhere plus index/update/bulk (but not delete) on Dashboards system indicesroles_mapping.ymlmaps the anonymous backend role to the custom roledocker compose down -vbecause OpenSearch applies security config to an internal index on first startupAnonymous user permissions
Test plan
OPENSEARCH_ANONYMOUS_AUTH=false(default) — verify login page appears and credentials are requiredOPENSEARCH_ANONYMOUS_AUTH=true, rundocker compose down -v && docker compose up -d— verify Dashboards loads without loginfalse, restart with-v— verify login page returns and previously created objects are preservedScreenshots
Issues Resolved
N/A
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.