From 7e7cd0ad7bd0da264cc235cb8c379a5d9864ecbd Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Tue, 10 Sep 2024 12:50:32 -0400 Subject: [PATCH] Modifies some method names and comments Signed-off-by: Darshit Chanpura --- .../plugins/NoOpResourceAccessControlPlugin.java | 8 ++++---- .../plugins/ResourceAccessControlPlugin.java | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/opensearch/plugins/NoOpResourceAccessControlPlugin.java b/server/src/main/java/org/opensearch/plugins/NoOpResourceAccessControlPlugin.java index af6e79e34f84c..c3fae97380186 100644 --- a/server/src/main/java/org/opensearch/plugins/NoOpResourceAccessControlPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/NoOpResourceAccessControlPlugin.java @@ -10,6 +10,7 @@ import org.opensearch.accesscontrol.resources.EntityType; import org.opensearch.accesscontrol.resources.ResourceSharing; +import org.opensearch.accesscontrol.resources.ShareWith; import java.util.List; import java.util.Map; @@ -55,11 +56,11 @@ public boolean hasPermission(String resourceId, String systemIndexName) { /** * @param resourceId if of the resource to be updated * @param systemIndexName index where this resource is defined - * @param revokeAccess a map that contains entries of entities with whom this resource should be shared with + * @param shareWith a map that contains entries of entities with whom this resource should be shared with * @return null since security plugin is disabled in the cluster */ @Override - public ResourceSharing shareWith(String resourceId, String systemIndexName, Map> revokeAccess) { + public ResourceSharing shareWith(String resourceId, String systemIndexName, ShareWith shareWith) { return null; } @@ -85,11 +86,10 @@ public boolean deleteResourceSharingRecord(String resourceId, String systemIndex } /** - * @param entity whose resource sharing entries are to be deleted * @return false since security plugin is disabled */ @Override - public boolean deleteAllResourceSharingRecordsFor(String entity) { + public boolean deleteAllResourceSharingRecordsForCurrentUser() { return false; } diff --git a/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java b/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java index 6bcd3150b59db..f23fdefda0230 100644 --- a/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java @@ -10,6 +10,7 @@ import org.opensearch.accesscontrol.resources.EntityType; import org.opensearch.accesscontrol.resources.ResourceSharing; +import org.opensearch.accesscontrol.resources.ShareWith; import java.util.List; import java.util.Map; @@ -50,12 +51,13 @@ public interface ResourceAccessControlPlugin { /** * Adds an entity to the share-with. Resource needs to be in restricted mode. - * @param resourceId if of the resource to be updated + * Creates a resource sharing record if one doesn't exist. + * @param resourceId id of the resource to be updated * @param systemIndexName index where this resource is defined - * @param entities a map that contains entries of entities with whom the resource should be shared with + * @param shareWith an object that contains entries of entities with whom the resource should be shared with * @return updated resource sharing record */ - ResourceSharing shareWith(String resourceId, String systemIndexName, Map> entities); + ResourceSharing shareWith(String resourceId, String systemIndexName, ShareWith shareWith); /** * Revokes given permission to a resource @@ -76,11 +78,11 @@ public interface ResourceAccessControlPlugin { boolean deleteResourceSharingRecord(String resourceId, String systemIndexName); /** - * Deletes all entries from .resource_sharing index where requested entity is the creator of the resource - * @param entity whose resource sharing records are to be deleted + * TODO check if this method is needed + * Deletes all entries from .resource_sharing index where current user is the creator of the resource * @return true if resource record was deleted, false otherwise */ - boolean deleteAllResourceSharingRecordsFor(String entity); + boolean deleteAllResourceSharingRecordsForCurrentUser(); // TODO: Check whether methods for bulk updates are required }