-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Introduces Centralized Resource Access Control and Sharing #5016
base: main
Are you sure you want to change the base?
[Feature] Introduces Centralized Resource Access Control and Sharing #5016
Conversation
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
…in action Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
… term Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
@nibix should the index be marked as hidden? On another note, this PR has been updated with integration test for sample plugin and these tests run with CI as well. Would you mind re-reviewing it? I'll be pushing the changes to fix code-cov CI. |
In case anyone needs help getting started with review, here is an order that you can follow.
|
Signed-off-by: Darshit Chanpura <[email protected]>
* | ||
* @opensearch.experimental | ||
*/ | ||
public interface ResourceSharingExtension { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Similar to previous comment, wdyt about naming this SharableResourceExtension
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO ResourceSharingExtension is more clear.
@@ -755,7 +796,10 @@ public Weight doCache(Weight weight, QueryCachingPolicy policy) { | |||
|
|||
@Override | |||
public void onPreQueryPhase(SearchContext context) { | |||
dlsFlsValve.handleSearchContext(context, threadPool, namedXContentRegistry.get()); | |||
CompletableFuture.runAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the comment in #5016 (comment) ... i fear, the issue described there still holds.
While the method suggests that the call is "async", the join()
call again blocks an OpenSearch thread which brings the risk of thread pool exhaustion and thus deadlocks. It just circumvents the assertion which is done in the actionGet()
method.
I am sorry to say, but I am pretty confident that it is not safely possible to make search requests within low level operations like onPreQueryPhase
or the lucene filter leaf readers. Even if it would be possible, the performance would be miserable, as this would cause the query to be fired thousands of times for a single user search.
I fear that a completely different approach is necessary:
- Filter level DLS was designed to allow DLS for term lookup queries which seems a thing which comes closest to the current approach.
- Alternatively, the whole resource sharing information must be kept in the Java heap.
Still, I have severe doubts whether DLS is really the correct way to tackle this issue.
Reasons:
- DLS does only cover read operations. It does not cover write operations and cannot be quickly extended to cover it. I guess, resource sharing, however, also needs support for write operations?
- I have doubts whether the equation "one resource is exactly one document" is really true. See also the question here: [Question] Should resource-sharing information be stored on a dedicated index or on the resource index inside the documents? #5014 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DLS does only cover read operations. It does not cover write operations and cannot be quickly extended to cover it. I guess, resource sharing, however, also needs support for write operations?
I think with the approach @DarshitChanpura took in this PR, there is a separate index that security owns and keeps track of the resource_user
(the owner of the resource) along with sharing info. Plugins reserve the right to write to their system indices, but if the index contains resources (as put forward in this feature) then behind-the-scenes security will filter the search request to only return resources pertinent to the authenticated user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind this approach was to prevent plugin dev errors. It was discussed as part of the PR in core. (comment). By implementing a DLS approach we do not require plugin devs to make any calls manually.
@reta @nibix @cwperks I think we need to align on the path forward. DLS or not? I've already introduced a sharing api as part of this PR.
src/main/java/org/opensearch/security/resources/ResourceAccessHandler.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/resources/ResourceAccessHandler.java
Show resolved
Hide resolved
yes, any system index which is not directly relevant to the end user should be not visible by default to the user. Thus, it should be marked as hidden. |
src/main/java/org/opensearch/security/configuration/DlsFlsValveImpl.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/configuration/SecurityFlsDlsIndexSearcherWrapper.java
Show resolved
Hide resolved
In this case the index is not technically directly relevant however when user shares the info or wants to check who has access to this resource. So I'm not sure if hidden still applies here. |
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
I've opened a discussion issue to finalize the approach. #5062 |
Description
Introduces a new authorization mechanism to control access to resources defined by plugins.
There are 4 major components to this PR:
Issues Resolved
Testing
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.