[Resource Access Control] [Part3] Introduces a sample plugin to demonstrate usage of Resource Access Control feature#5187
Conversation
…rol, and add extensive integration tests Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
…ster Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
16774d1 to
4c21bbd
Compare
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
…into sample-resource-plugin-spi
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
a4bf285 to
e13e81f
Compare
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
… fetch all resource-ids for a user Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/resource-permissions #5187 +/- ##
=================================================================
+ Coverage 0 70.52% +70.52%
=================================================================
Files 0 342 +342
Lines 0 23175 +23175
Branches 0 3591 +3591
=================================================================
+ Hits 0 16344 +16344
- Misses 0 5057 +5057
- Partials 0 1774 +1774
🚀 New features to boost your workflow:
|
...esource-plugin/src/integrationTest/java/org/opensearch/sample/SampleResourcePluginTests.java
Outdated
Show resolved
Hide resolved
...ionTest/java/org/opensearch/sample/nonsystemindex/ResourceNonSystemIndexSIDisabledTests.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
| /** | ||
| * This abstract class defines common tests between different feature flag scenarios | ||
| */ | ||
| public abstract class AbstractSampleResourcePluginFeatureEnabledTests extends AbstractSampleResourcePluginTests { |
There was a problem hiding this comment.
I'd recommend to avoid super classes for test classes, as these take away flexibility and composability, as you can have only one super class. Additionally, the inherited @test methods make it quite difficult to understand what is being tested. IMHO, one should follow the "composition over inheritance" pattern and use references to other classes intead.
There was a problem hiding this comment.
The tests are common for feature enabled scenarios. This class is inherited by 3 tests which implement 3 scenarios: User with full access, user with limited access and direct access when system index feature is disabled. The super-class test suite was added only to avoid duplicated tests-code.
...egrationTest/java/org/opensearch/sample/AbstractSampleResourcePluginFeatureEnabledTests.java
Outdated
Show resolved
Hide resolved
...plugin/src/integrationTest/java/org/opensearch/sample/AbstractSampleResourcePluginTests.java
Outdated
Show resolved
Hide resolved
sample-resource-plugin/src/main/java/org/opensearch/sample/SampleResourceScope.java
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Using @SuppressWarnings("unchecked") on untrusted input (the request body source) bears the risk of getting ClassCastExceptions deep inside the application code. While this is usually not security critical, it might locating the root cause of issues diificult - both for admins and for end users.
There was a problem hiding this comment.
I agree. However this is is a sample plugin and hence should be fine IMO.
There was a problem hiding this comment.
Well, the primary purpse of sample plugins is to give other developers an idea/blueprint on how to design their own code. Thus, there is a big chance that developers will follow any pattern displayed in that code base, including bad patterns.
And, experience shows that developers have the tendency to follow patterns they are finding in existing code bases, no matter how bad these actually might be.
IMHO, to cope for this, we should add in such cases at least a comment like "this is just done for simplicity, do not do that for real plugins".
There was a problem hiding this comment.
We do use this pattern at a decent number of places in security plugin. Here is one such example. I will add a comment here stating suppressing should be avoided in real-world, however there is no mechanism to stop plugin's from implementing it.
There was a problem hiding this comment.
There are different "risk classes" of using @SuppressWarnings("unchecked"). For the example you have linked, it is possible to argue within a minute that this is actually a safe cast and no late ClassCastExceptions can be caused by it.
.../java/org/opensearch/sample/resource/actions/rest/revoke/RevokeResourceAccessRestAction.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
04aa12d
into
opensearch-project:feature/resource-permissions
|
Merged this feature-branch PR as i didn't see amy blocking reviews. The PR against main is already open and is the last step to getting this feature merged. |
…strate usage of Resource Access Control feature (opensearch-project#5187) Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
…strate usage of Resource Access Control feature (#5187) Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
#5016 is being broken down into smaller pieces. This is part 3.
Description
Introduces a sample resource plugin that demonstrate usage of
opensearch-security-spifor resource access control.Issues Resolved
Related to #4500
Testing
Check List
~- [ ] New Roles/Permissions have a corresponding security dashboards plugin PR
- [ ] API changes companion pull request createdBy 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.