Create a mechanism for plugins to explicitly declare actions they need to perform with their assigned PluginSubject#5341
Conversation
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
nibix
left a comment
There was a problem hiding this comment.
Generally, it looks good to me. I have left a few minor comments.
I have left one comment regarding mixing roles for normal users and for plugin users. I am wondering whether it could make sense to keep things a bit more strict apart by having two instances of ActionPrivileges: One for normal users, one for plugin users.
This would make any concerns about overlapping role names impossible. Additionally, the ActionPrivileges instance for plugin users would only be created once and could stay constant during the rest of the node life-time.
...resource-plugin/src/integrationTest/java/org/opensearch/sample/secure/SecurePluginTests.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/securityconf/impl/v7/RoleV7.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/security/privileges/ActionPrivilegesTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/privileges/ActionPrivileges.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/privileges/ActionPrivileges.java
Outdated
Show resolved
Hide resolved
We can certainly do this. FYI I was also thinking of following a similar pattern for API Tokens (PR on my own fork atm which I plan to contribute to the feature branch on this repo) where there would be a convention that when authenticating with an api token that the "User" in the ThreadContext would start with a prefix like |
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Yes, it seems to be a common use case to have role-independent action privileges. It might make sense to have a look at the class wether we can refactor it in a way that role-independent action privileges (for API tokens and plugins) are easier to achieve. If you want, I can try to build a quick protoype for that. |
Any help is appreciated :). |
src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/privileges/SystemIndexAccessEvaluator.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
src/test/java/org/opensearch/security/securityconf/impl/v7/RoleV7Test.java
Show resolved
Hide resolved
sample-resource-plugin/src/main/java/org/opensearch/sample/utils/RunAsSubjectClient.java
Show resolved
Hide resolved
nibix
left a comment
There was a problem hiding this comment.
Minor nits, but already looks very good to me.
Signed-off-by: Craig Perkins <cwperx@amazon.com>
DarshitChanpura
left a comment
There was a problem hiding this comment.
left some nits. Looks good otherwise!
...resource-plugin/src/integrationTest/java/org/opensearch/sample/secure/SecurePluginTests.java
Show resolved
Hide resolved
sample-resource-plugin/src/main/resources/plugin-additional-permissions.yml
Show resolved
Hide resolved
src/main/java/org/opensearch/security/privileges/SystemIndexAccessEvaluator.java
Show resolved
Hide resolved
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
…d to perform with their assigned PluginSubject (opensearch-project#5341) Signed-off-by: Craig Perkins <cwperx@amazon.com> Signed-off-by: Aiden Lindsay <aiden.o.lindsay@gmail.com>
…d to perform with their assigned PluginSubject (opensearch-project#5341) Signed-off-by: Craig Perkins <cwperx@amazon.com> Signed-off-by: Aiden Lindsay <aiden.o.lindsay@gmail.com>
Description
This PR allows plugins to define a
plugin-permissions.ymlfile (available on the extending plugin's classpath) which contains the set of permissions it needs to run with outside of the regular system index access that plugins can already perform with their assigned PluginSubject.For instance, the security plugin needs to be able to write to the auditlog index even though the auditlog index is not a system index. For this usecase, the plugin would add an
index_permissions:section in itsplugin-permissions.ymlfile that allows it to create and write to indices matching thesecurity_auditlog*pattern.This PR relates to strengthening system index access by deprecating
try (ThreadContext.StoredContext ctx = threadContext.stashContext()) { ... }which allow plugins to perform any action on the cluster in that block.With the replacement,
pluginSubject.runAs(() -> { ... }plugins are only limited to system index access for system indices that they formally register withSystemIndexPlugin.getSystemIndexDescriptors().This PR gives plugins an additional mechanism for declaring other necessary actions they need to perform with their assigned subject.
Enhancement
Issues Resolved
Replacement for opensearch-project/OpenSearch#15778 that does not require changes in the core
Related to: #4439
Check 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.