Skip to content

Commit

Permalink
feat: Apply workspace permission check when bulk creating object
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Jul 28, 2023
1 parent efbb1ce commit 01e21a2
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ export class WorkspaceSavedObjectsClientWrapper {
objects: Array<SavedObjectsBulkCreateObject<T>>,
options: SavedObjectsCreateOptions = {}
): Promise<SavedObjectsBulkResponse<T>> => {
if (options.workspaces) {
options.workspaces = options.workspaces.filter(
async (workspaceId) =>
await this.permissionControl.validate(
workspaceId,
WorkspacePermissionMode.Admin,
wrapperOptions.request
)
);
}
return await wrapperOptions.client.bulkCreate(objects, options);
};

Expand Down

0 comments on commit 01e21a2

Please sign in to comment.