Skip to content

fix: added OpenSearch security calls under feature flag#1296

Merged
edwinjosechittilappilly merged 21 commits intorelease-saas-0.1from
fix/opensearch_calls
Apr 8, 2026
Merged

fix: added OpenSearch security calls under feature flag#1296
edwinjosechittilappilly merged 21 commits intorelease-saas-0.1from
fix/opensearch_calls

Conversation

@lucaseduoli
Copy link
Copy Markdown
Collaborator

@lucaseduoli lucaseduoli commented Mar 30, 2026

This pull request introduces a new set of OpenSearch security configurations specifically for cloud deployments, improves the application of Document-Level Security (DLS), and adds a comprehensive test script for validating ACL enforcement. It also updates Dockerfiles to include the new security configuration files and makes minor improvements to the OpenSearch index initialization process.

Cloud Security Configuration:

  • Adds a new cloud_securityconfig/ directory with OpenSearch security configuration files for cloud environments, including roles.yml, roles_mapping.yml, config.yml, internal_users.yml, and others. These files define custom roles (such as openrag_user_role), role mappings, authentication domains (OIDC and internal), and DLS rules for fine-grained access control. [1] [2] [3] [4] [5] [6] [7]

  • Updates the main securityconfig/roles.yml to include additional permissions and index patterns, ensuring parity with cloud settings and better DLS support. [1] [2]

Dockerfile and Build Updates:

  • Modifies both Dockerfile and Dockerfile.backend to copy the new cloud_securityconfig/ directory into the build context and runtime images, and ensures correct file ownership for both standard and cloud security configs. [1] [2] [3]

Testing and Validation:

  • Adds a new script scripts/test.sh that performs end-to-end validation of OpenSearch ACLs and DLS. The script checks cluster health, verifies user roles, inspects index mappings, and tests document visibility for different users, both with and without application-level ACL filters.

Backend Improvements:

  • Updates the OpenSearch index initialization logic in src/api/settings.py to use the correct function and pass the admin username when IBM authentication is enabled, improving clarity and correctness during onboarding. [1] [2]

@lucaseduoli lucaseduoli self-assigned this Mar 30, 2026
@github-actions github-actions bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. labels Mar 30, 2026
@lucaseduoli lucaseduoli changed the title fix: added IBM security calls under feature flag fix: added OpenSearch security calls under feature flag Mar 30, 2026
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 30, 2026
Comment thread src/main.py
@lucaseduoli lucaseduoli changed the base branch from main to release-saas-0.1 March 30, 2026 15:09
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 30, 2026
Comment thread src/main.py Outdated
@lucaseduoli lucaseduoli force-pushed the fix/opensearch_calls branch from eac55b2 to 6998235 Compare March 30, 2026 15:14
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 30, 2026
Comment thread src/utils/opensearch_utils.py Outdated
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crititcal issues with Docker image

@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 30, 2026
@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@lucaseduoli 2 critical updates:

  1. copy security config folder to backend image.
  2. Currently the security config is applied to the docuemts folder for indexs and other folders, but the user might use a different index name from env, just like we do for deployemnts.
    Hence we need to ensure to add this index name dynamically to that list.

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

example:

    - index_patterns: ["documents", "documents*", "knowledge_filters", "knowledge_filters*"]

in roles.yml and downstream api calls that uses this.

@github-actions github-actions bot added docker bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 30, 2026
@github-actions github-actions bot added the bug 🔴 Something isn't working. label Apr 2, 2026
Grant additional index and cluster permissions for openrag_user_role in both securityconfig and cloud_securityconfig: add indices:admin/refresh and indices:data/write/delete|update/byquery, introduce an api_keys (api_keys*) entry with CRUD and mappings permissions constrained by a DLS on user_id, and allow CRUD on .opendistro-alerting-config. Also add cluster:monitor/* to securityconfig and update .gitignore to ignore /opensearch-data2.
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 2, 2026
When building role index_permissions, only append the dynamic current index (and its wildcard) to entries that include a DLS filter. Previously the index name was added to any permission with index_patterns, which could cause OpenSearch to prefer a no-DLS entry (e.g. alerting config) and bypass filtering. The change adds an explicit check for "dls" on the permission, preserves knowledge_filters, avoids duplicates, and sorts the resulting patterns.
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 6, 2026
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 7, 2026
Add orag-* to openrag_user_role index patterns. Refactor setup_opensearch_security to stop injecting the current index into role DLS entries and instead fetch and merge existing all_access role mappings. The code now preserves existing users, hosts, and backend_roles (excluding the all_access backend role), and appends both the plain admin username and its ibmlhapikey_ variant when IBM auth is enabled, ensuring multi-tenant deployments don't lose prior admins. Also remove the unused get_index_name import and improve logging when no existing mapping is found.
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 8, 2026
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 8, 2026
Avoid AttributeError when OPENSEARCH_JWT_TOKEN is not set. Add a truthiness check so startswith is only called if token is not None/empty. Existing fallback to jwt.encode remains unchanged.
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 8, 2026
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the lgtm label Apr 8, 2026
Include `orag*` in index_patterns for openrag_user_role so indices without the hyphen (e.g. `orag123`) are matched in addition to `orag-*`. Note: the added pattern is unquoted in the file; consider quoting it ("orag*") to avoid potential YAML parsing issues.
@github-actions github-actions bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Apr 8, 2026
@edwinjosechittilappilly edwinjosechittilappilly merged commit 1b26ab1 into release-saas-0.1 Apr 8, 2026
6 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fix/opensearch_calls branch April 8, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. DO NOT MERGE docker lgtm tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants