Skip to content

Commit

Permalink
Only log saved object which have no permission
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Sep 11, 2023
1 parent ada1a01 commit ea48051
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/core/server/saved_objects/permission_control/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,28 @@ export class SavedObjectsPermissionControl {
}

const principals = this.getPrincipalsFromRequest(request);
let savedObjectsBasicInfo: any[] = [];
const hasAllPermission = savedObjectsGet.every((item) => {
// for object that doesn't contain ACL like config, return true
if (!item.permissions) {
return true;
}
const aclInstance = new ACL(item.permissions);
return aclInstance.hasPermission(permissionModes, principals);
const hasPermission = aclInstance.hasPermission(permissionModes, principals);
if (!hasPermission) {
savedObjectsBasicInfo = [
...savedObjectsBasicInfo,
{
id: item.id,
type: item.type,
workspaces: item.workspaces,
permissions: item.permissions,
},
];
}
return hasPermission;
});
if (!hasAllPermission) {
const savedObjectsBasicInfo = savedObjectsGet.map((item) => {
return {
id: item.id,
type: item.type,
workspaces: item.workspaces,
permissions: item.permissions,
};
});
this.logger.debug(
`Authorization failed, principals: ${JSON.stringify(
principals
Expand Down

0 comments on commit ea48051

Please sign in to comment.