diff --git a/plugins/rbac-backend/src/role-manager/ancestor-search-memo.ts b/plugins/rbac-backend/src/role-manager/ancestor-search-memo.ts index 24f193ee25..e436a70264 100644 --- a/plugins/rbac-backend/src/role-manager/ancestor-search-memo.ts +++ b/plugins/rbac-backend/src/role-manager/ancestor-search-memo.ts @@ -147,7 +147,6 @@ export class AncestorSearchMemo { return; } - const groupsRefs = new Set(); const groupName = `group:${group.metadata.namespace?.toLocaleLowerCase( 'en-US', )}/${group.metadata.name.toLocaleLowerCase('en-US')}`; @@ -161,13 +160,12 @@ export class AncestorSearchMemo { if (parentGroup) { const parentName = `group:${group.metadata.namespace?.toLocaleLowerCase( 'en-US', - )}/${parent.toLocaleLowerCase('en-US')}`; + )}/${parentGroup.metadata.name.toLocaleLowerCase('en-US')}`; memo.setEdge(parentName, groupName); - groupsRefs.add(parentName); - } - if (groupsRefs.size > 0 && memo.isAcyclic()) { - this.traverseGroups(memo, parentGroup!, allGroups, depth); + if (memo.isAcyclic()) { + this.traverseGroups(memo, parentGroup, allGroups, depth); + } } } @@ -194,7 +192,7 @@ export class AncestorSearchMemo { ); if (parentGroup && memo.isAcyclic()) { - this.traverseRelations(memo, parentGroup!, allRelations, depth); + this.traverseRelations(memo, parentGroup, allRelations, depth); } }