From c00e1d01d332b570f913ead6f42b5a3461997eb4 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 20 Dec 2024 09:38:32 -0500 Subject: [PATCH] Remove allowed_actions Signed-off-by: Craig Perkins --- .../opensearch/security/spi/ShareWith.java | 23 ++++--------------- .../rest/resource/ShareWithRestAction.java | 6 +---- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/spi/src/main/java/org/opensearch/security/spi/ShareWith.java b/spi/src/main/java/org/opensearch/security/spi/ShareWith.java index 08fcd99d38..dfb0ba0272 100644 --- a/spi/src/main/java/org/opensearch/security/spi/ShareWith.java +++ b/spi/src/main/java/org/opensearch/security/spi/ShareWith.java @@ -12,31 +12,27 @@ public class ShareWith implements NamedWriteable, ToXContentFragment { - public final static ShareWith PRIVATE = new ShareWith(List.of(), List.of(), List.of("*")); - public final static ShareWith PUBLIC = new ShareWith(List.of("*"), List.of("*"), List.of("*")); + public final static ShareWith PRIVATE = new ShareWith(List.of(), List.of()); + public final static ShareWith PUBLIC = new ShareWith(List.of("*"), List.of("*")); - private final List allowedActions; private final List users; private final List backendRoles; - public ShareWith(List users, List backendRoles, List allowedActions) { + public ShareWith(List users, List backendRoles) { this.users = users; this.backendRoles = backendRoles; - this.allowedActions = allowedActions; } public ShareWith(StreamInput in) throws IOException { this.users = in.readStringList(); this.backendRoles = in.readStringList(); - this.allowedActions = in.readStringList(); } @SuppressWarnings("unchecked") public static ShareWith fromSource(Map sourceAsMap) { List users = (List) sourceAsMap.get("users"); List backendRoles = (List) sourceAsMap.get("backend_roles"); - List allowedActions = (List) sourceAsMap.get("allowed_actions"); - return new ShareWith(users, backendRoles, allowedActions); + return new ShareWith(users, backendRoles); } public List getUsers() { @@ -47,17 +43,9 @@ public List getBackendRoles() { return backendRoles; } - public List getAllowedActions() { - return allowedActions; - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - return builder.startObject() - .field("users", users) - .field("backend_roles", backendRoles) - .field("allowed_actions", allowedActions) - .endObject(); + return builder.startObject().field("users", users).field("backend_roles", backendRoles).endObject(); } @Override @@ -69,6 +57,5 @@ public String getWriteableName() { public void writeTo(StreamOutput out) throws IOException { out.writeStringCollection(users); out.writeStringCollection(backendRoles); - out.writeStringCollection(allowedActions); } } diff --git a/src/main/java/org/opensearch/security/rest/resource/ShareWithRestAction.java b/src/main/java/org/opensearch/security/rest/resource/ShareWithRestAction.java index 1d50c497be..556fa16ff5 100644 --- a/src/main/java/org/opensearch/security/rest/resource/ShareWithRestAction.java +++ b/src/main/java/org/opensearch/security/rest/resource/ShareWithRestAction.java @@ -71,11 +71,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client } Map shareWithMap = (Map) source.get("share_with"); - ShareWith shareWith = new ShareWith( - (List) shareWithMap.get("users"), - (List) shareWithMap.get("backend_roles"), - (List) shareWithMap.get("allowed_actions") - ); + ShareWith shareWith = new ShareWith((List) shareWithMap.get("users"), (List) shareWithMap.get("backend_roles")); final ShareWithRequest shareWithRequest = new ShareWithRequest(resourceId, resourceTypeToIndexMap.get(resourceType), shareWith); return channel -> client.executeLocally(ShareWithAction.INSTANCE, shareWithRequest, new RestToXContentListener<>(channel));