Skip to content

Commit

Permalink
fix(rbac): fix bug with restart instance
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <[email protected]>
  • Loading branch information
AndrienkoAleksandr committed Jul 5, 2024
1 parent 77edf3a commit 4b55043
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugins/rbac-backend/src/audit-log/audit-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const RoleEvents = {
CREATE_ROLE: 'CreateRole',
UPDATE_ROLE: 'UpdateRole',
DELETE_ROLE: 'DeleteRole',
CREATE_OR_UPDATE_ROLE: 'CreateOrUpdateRole',
GET_ROLE: 'GetRole',

CREATE_ROLE_ERROR: 'CreateRoleError',
Expand Down
6 changes: 4 additions & 2 deletions plugins/rbac-backend/src/service/permission-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ const useAdminsFromConfig = async (
const entityRef = admin.getString('name');
validateEntityReference(entityRef);

addedGroupPolicies.set(entityRef, ADMIN_ROLE_NAME);
if (!(await enf.hasGroupingPolicy(...[entityRef, ADMIN_ROLE_NAME]))) {
addedGroupPolicies.set(entityRef, ADMIN_ROLE_NAME);
}
}

const adminRoleMeta =
Expand Down Expand Up @@ -108,7 +110,7 @@ const useAdminsFromConfig = async (
await auditLogger.auditLog<RoleAuditInfo>({
actorId: RBAC_BACKEND,
message: `Created or updated role`,
eventName: RoleEvents.CREATE_ROLE,
eventName: RoleEvents.CREATE_OR_UPDATE_ROLE,
metadata: {
...getAdminRoleMetadata(),
members: addedRoleMembers.map(gp => gp[0]),
Expand Down

0 comments on commit 4b55043

Please sign in to comment.