Skip to content

Commit

Permalink
fix: delete workspace role binding when workspace group is added
Browse files Browse the repository at this point in the history
Signed-off-by: Youngjin Jo <[email protected]>
  • Loading branch information
yjinjo committed Sep 30, 2024
1 parent 48481a1 commit 063e0f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/spaceone/identity/service/workspace_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def _add_workspace_to_group(
if old_workspace_group_id:
if old_workspace_group_id != workspace_group_id:
self._delete_role_bindings(
workspace_id, old_workspace_group_id, domain_id
workspace_id, domain_id, old_workspace_group_id
)

self._create_role_bindings(
Expand Down Expand Up @@ -459,6 +459,7 @@ def _add_workspace_to_group(
else:
is_updatable = False
else:
self._delete_role_bindings(workspace_id, domain_id)
self._create_role_bindings(
workspace_group_vo.users,
workspace_id,
Expand All @@ -478,7 +479,7 @@ def _remove_workspace_from_group_with_workspace_vo(
self, workspace_vo: Workspace, old_workspace_group_id: str, domain_id: str
) -> None:
workspace_id = workspace_vo.workspace_id
self._delete_role_bindings(workspace_id, old_workspace_group_id, domain_id)
self._delete_role_bindings(workspace_id, domain_id, old_workspace_group_id)

workspace_vo.changed_at = datetime.utcnow()
workspace_vo.workspace_group_id = None
Expand All @@ -504,12 +505,12 @@ def _remove_workspace_from_group_with_workspace_vo(
)

def _delete_role_bindings(
self, workspace_id: str, existing_workspace_group_id: str, domain_id: str
self, workspace_id: str, domain_id: str, existing_workspace_group_id: str = None
):
rb_vos = self.rb_mgr.filter_role_bindings(
workspace_id=workspace_id,
workspace_group_id=existing_workspace_group_id,
domain_id=domain_id,
workspace_group_id=existing_workspace_group_id,
)
for rb_vo in rb_vos:
self.rb_mgr.delete_role_binding_by_vo(rb_vo)
Expand Down

0 comments on commit 063e0f3

Please sign in to comment.