Skip to content
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

[Resource Access Control] [Part2] Introduces a client for Resource Access Control and adds concrete implementation for resource access control #5194

Open
wants to merge 19 commits into
base: feature/resource-permissions
Choose a base branch
from

Conversation

DarshitChanpura
Copy link
Member

@DarshitChanpura DarshitChanpura commented Mar 20, 2025

#5185 must be merged before merging this.

#5016 is being broken down into smaller pieces. This is part 2.

Description

Introduces a client to be consumed by plugins, and adds concrete implementation of ResourceAccessControl.

There are 4 java APIs as well as 4 REST APIs introduced as part of this PR. Plugins will leverage the client to call the java APIs to implement resource access control.

Refer to the RESOURCE_ACCESS_CONTROL_FOR_PLUGINS.md file to understand in-depth implementation of this feature.

Issues Resolved

Testing

  • automated tests + manual tests

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
    - [ ] API changes companion pull request created
  • Commits are signed per the DCO using --signoff

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.

@DarshitChanpura DarshitChanpura force-pushed the resource-sharing-client branch from 33c2dc4 to 89d3a63 Compare March 20, 2025 18:33
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
@DarshitChanpura DarshitChanpura force-pushed the resource-sharing-client branch from 597172b to 52f4ac5 Compare March 20, 2025 20:38
@DarshitChanpura DarshitChanpura changed the title [Resource Access Control] [Part2] Introduces a client for Resource Access Control and adds concrete implementation via common package [Resource Access Control] [Part2] Introduces a client for Resource Access Control and adds concrete implementation for resource access control Mar 20, 2025
Copy link
Collaborator

@nibix nibix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this interesting PR @DarshitChanpura !

I have added a couple of comments and questions. As I went through the code linearly, I also commented both on conceptual things and code level things (which I mostly marked with Nit:). I would recommend that you first have a look on conceptual things ... we can talk about the Nit stuff later.

If you want, we can also schedule a conversation at some point in time.

@DarshitChanpura DarshitChanpura force-pushed the resource-sharing-client branch from e38b67e to e05ae8a Compare March 21, 2025 22:26
@DarshitChanpura DarshitChanpura force-pushed the resource-sharing-client branch from d3b4304 to 31b0d0b Compare March 26, 2025 21:45
Comment on lines +404 to +406
"entities_to_revoke": {
"roles": ["shared-roles"]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be modified w.r.t. default action group?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is just a list of entities. Action-groups will be supplied separately (not in scope of v1)

Comment on lines +452 to +459
- **Endpoint:**
```
GET /_plugins/_security/resources/list/{resource_index}
```
- **Description:**
Retrieves a list of **resources that the current user has access to** within the specified `{resource_index}`.

#### **Response:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the performance implications of the "extra hop" with the resource sharing security index?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed during the design phase, there are is no concept of joins in OpenSearch. So the alternative to current approach would be to store resource data inside resource-sharing index, which results in significant amount of duplication and something we are moving away from.

resourceSharingClient.verifyResourceAccess(
resourceId,
RESOURCE_INDEX_NAME,
SampleResourceScope.PUBLIC.value(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this if we are removing the concept of scopes from this change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay


#### **Method Signature:**
```java
void shareResource(String resourceId, String resourceIndex, Map<String, Object> shareWith, ActionListener<ResourceSharing> listener);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about this and other similar methods - since we know that the keys would be "roles", "users", and "backend_roles", can we somehow enforce that they provide a ShareWith datastructure, instead of accepting an arbitrary map here?

Copy link
Member Author

@DarshitChanpura DarshitChanpura Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will eventually be replaced with ShareWith class. I can replace it for now to be of type: SharedWithActionGroup.ActionGroupRecipient

Comment on lines +188 to +204
private String securityOrFeatureDisabledMessage() {
boolean sharingEnabled = settings.getAsBoolean(
ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED,
ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT
);

Settings securitySettings = settings.getByPrefix(ConfigConstants.SECURITY_SETTINGS_PREFIX);
boolean securityDisabled = securitySettings.isEmpty()
|| this.settings.getAsBoolean(
ConfigConstants.OPENSEARCH_SECURITY_DISABLED,
ConfigConstants.OPENSEARCH_SECURITY_DISABLED_DEFAULT
);

if (securityDisabled) return "Security Plugin is disabled.";
if (!sharingEnabled) return "ShareableResource Access Control feature is disabled.";
return "";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we want to check here whether system index protections is enabled, and also return a message if so? Since the feature is dependent on that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checked at Transport Actions since that is the common sink between Rest APIs and client. Checkout ShareResourceTransportAction

* @return True if the resource is owned by the user, false otherwise.
*/
private boolean isOwnerOfResource(ResourceSharing document, String userName) {
return document.getCreatedBy() != null && document.getCreatedBy().getCreator().equals(userName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question/concern here is whether username would be guaranteed to be unique, specifically when considering multiple SSO providers/internal users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants