Allow plugins to bring a default-roles.yml file with static list of roles to use plugin#6038
Merged
cwperks merged 1 commit intoopensearch-project:mainfrom Mar 26, 2026
Merged
Conversation
…oles to use plugin Signed-off-by: Craig Perkins <cwperx@amazon.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6038 +/- ##
==========================================
+ Coverage 73.79% 73.81% +0.01%
==========================================
Files 440 441 +1
Lines 27259 27379 +120
Branches 4052 4081 +29
==========================================
+ Hits 20117 20211 +94
- Misses 5227 5243 +16
- Partials 1915 1925 +10
🚀 New features to boost your workflow:
|
DarshitChanpura
approved these changes
Mar 26, 2026
Member
DarshitChanpura
left a comment
There was a problem hiding this comment.
nice addition!! lets update documentation as well
Member
Author
|
^ I'll follow-up this PR with doc update and adding a CHANGELOG. I'm currently waiting until the CHANGELOG is cleared to avoid conflict. |
RyanL1997
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a mechanism for OpenSearch plugins to contribute their own default roles via a
default-roles.ymlfile bundled in their classpath resources. Currently, the security plugin'sconfig/roles.ymlcentralizes default roles from many different plugins (alerting, anomaly detection, kNN, ML, etc.), which is problematic because plugins can be installed or removed independently by cluster admins.This follows the same pattern established by
resource-access-levels.ymlfor plugin-provided action groups.Category: New feature
Why these changes are required?
The security plugin should not be the central repository for roles that belong to other plugins. Each plugin knows best what roles it needs, and those roles should travel with the plugin — installed when the plugin is installed, gone when it's removed. This also lays the groundwork for future hot-reloadability of static configs.
Old behavior: All default roles for every plugin are defined in the security plugin's
config/roles.ymlandstatic_roles.yml. Plugins have no way to contribute their own role definitions.New behavior: Plugins can include a
default-roles.ymlfile in their classpath resources and implement theSecurityConfigExtensionSPI interface. The security plugin discovers these at startup viaExtensionLoader, loads the YAML files, and merges them into the static roles pool. Plugin-provided roles are held in-memory only (never persisted to the security index), marked as static and reserved, and take precedence over entries instatic_roles.ymland the security index when a name collision exists.Key changes:
SecurityConfigExtensionSPI marker interface in thespimodule — any plugin can implement this to contribute static security configResourceSharingExtensionnow extendsSecurityConfigExtension, so resource-sharing plugins get this capability for freePluginDefaultRolesHelperclass that discovers and loadsdefault-roles.ymlfrom plugin classloaders (with URL-based deduplication for plugins that register multiple extensions sharing a classloader)DynamicConfigFactoryupdated to merge plugin default roles in both theonChange()path and theaddStatics()path, with plugin roles taking highest precedencedefault-roles.ymldemonstrating the patternPrecedence chain: plugin
default-roles.yml> securitystatic_roles.yml> security index entriesIssues Resolved
To be filed
Is this a backport? No
Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end? No
Testing
DefaultRolesTestsadded to the sample resource plugin covering:default-roles.ymlCheck List
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](https://github.com/opensearch-project/security/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).