Skip to content

Commit

Permalink
Remove allowed_actions
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Dec 20, 2024
1 parent c9cf55f commit c00e1d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
23 changes: 5 additions & 18 deletions spi/src/main/java/org/opensearch/security/spi/ShareWith.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> allowedActions;
private final List<String> users;
private final List<String> backendRoles;

public ShareWith(List<String> users, List<String> backendRoles, List<String> allowedActions) {
public ShareWith(List<String> users, List<String> 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<String, Object> sourceAsMap) {
List<String> users = (List<String>) sourceAsMap.get("users");
List<String> backendRoles = (List<String>) sourceAsMap.get("backend_roles");
List<String> allowedActions = (List<String>) sourceAsMap.get("allowed_actions");
return new ShareWith(users, backendRoles, allowedActions);
return new ShareWith(users, backendRoles);
}

public List<String> getUsers() {
Expand All @@ -47,17 +43,9 @@ public List<String> getBackendRoles() {
return backendRoles;
}

public List<String> 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
Expand All @@ -69,6 +57,5 @@ public String getWriteableName() {
public void writeTo(StreamOutput out) throws IOException {
out.writeStringCollection(users);
out.writeStringCollection(backendRoles);
out.writeStringCollection(allowedActions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client
}

Map<String, Object> shareWithMap = (Map<String, Object>) source.get("share_with");
ShareWith shareWith = new ShareWith(
(List<String>) shareWithMap.get("users"),
(List<String>) shareWithMap.get("backend_roles"),
(List<String>) shareWithMap.get("allowed_actions")
);
ShareWith shareWith = new ShareWith((List<String>) shareWithMap.get("users"), (List<String>) shareWithMap.get("backend_roles"));

final ShareWithRequest shareWithRequest = new ShareWithRequest(resourceId, resourceTypeToIndexMap.get(resourceType), shareWith);
return channel -> client.executeLocally(ShareWithAction.INSTANCE, shareWithRequest, new RestToXContentListener<>(channel));
Expand Down

0 comments on commit c00e1d0

Please sign in to comment.