-
Notifications
You must be signed in to change notification settings - Fork 284
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]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
… resource-sharing-spi
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
6498c44
to
decf32d
Compare
Signed-off-by: Darshit Chanpura <[email protected]>
decf32d
to
85c4556
Compare
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
…I to maven publish task and updates SPI readme Signed-off-by: Darshit Chanpura <[email protected]>
f6472d8
to
534838f
Compare
sample-resource-plugin/src/main/java/org/opensearch/sample/SampleResourcePlugin.java
Outdated
Show resolved
Hide resolved
/** | ||
* Marker interface for all resources | ||
*/ | ||
public abstract class Resource implements NamedWriteable, ToXContentFragment { |
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.
Why is this an abstract class instead of an interface? With an abstract class, the implementer cannot extend other classes for their resources.
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 is that a Resource must only extend this class. The reason why it is abstract is that I want to enforce a constructor of type Resource(StreamInput in) be created.
@@ -383,6 +384,7 @@ public class SearchOperationTest { | |||
new AuditConfiguration(true).compliance(new AuditCompliance().enabled(true)) | |||
.filters(new AuditFilters().enabledRest(true).enabledTransport(true)) | |||
) | |||
.nodeSettings(Map.of(OPENSEARCH_RESOURCE_SHARING_ENABLED, false)) |
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.
Why is this necessary here?
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 feature is enabled by default. Which means that the resource sharing index will be created which caused shouldGetFieldCapabilitiesForAllIndexes_positive
to fail on containsExactlyIndices
assertion. The other option to not adding this flag is to add that assertion. However, for the sake of this test, since it is not resource-sharing related, I added a flag to disable it.
src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java
Outdated
Show resolved
Hide resolved
@@ -224,6 +224,7 @@ public boolean authenticate(final SecurityRequestChannel request) { | |||
if (adminDns.isAdminDN(sslPrincipal)) { | |||
// PKI authenticated REST call | |||
threadContext.putTransient(ConfigConstants.OPENDISTRO_SECURITY_USER, new User(sslPrincipal)); | |||
threadContext.putPersistent(ConfigConstants.OPENDISTRO_SECURITY_USER, new User(sslPrincipal)); |
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.
How is this change related to resource sharing?
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.
Since writing to a resource index maybe a stashed operation, we might lose the context of the requested user. To prevent that we store the user as a persistent header which will then be retrieved while fetching current user's resources, verifying access or creating a resource.
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.
In long term we do intend to change this to a persistent header and remove transient completely.
|
||
searchRequest.source(searchSourceBuilder); | ||
|
||
SearchResponse searchResponse = client.search(searchRequest).actionGet(); |
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.
Sync operations in low level OpenSearch code are bound to make issues. As soon this is executed on a transport thread, this will fail.
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.
Could you explain a bit more in detail?
if (this.isResourceSharingEnabled | ||
&& !Strings.isNullOrEmpty(indexName) | ||
&& OpenSearchSecurityPlugin.getResourceIndices().contains(indexName)) { | ||
resourceIds = this.resourceAccessHandler.getAccessibleResourceIdsForCurrentUser(indexName); |
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.
Under the hood, this makes a sync index operation.
We are here in an extremely low level operation. I am pretty sure that this will not work, even if it would be an async operation (which it cannot be due to the API constraints).
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.
Could you explain a bit more in detail?
Signed-off-by: Darshit Chanpura <[email protected]>
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.