Skip to content

Commit

Permalink
FWF-3325: [Feature] Added tenantKey to main group
Browse files Browse the repository at this point in the history
  • Loading branch information
auslin-aot committed Jun 6, 2024
1 parent 203efc3 commit 90c7a35
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,16 @@ def delete_group(self, group_id: str):

@user_context
def create_group_role(self, data: Dict, **kwargs):
"""Create role."""
"""Create tenant group."""
current_app.logger.debug("Creating tenant group...")
user: UserContext = kwargs["user"]
tenant_key = user.tenant_key
# Append tenantKey to group in the group hierarchy.
# If user input is "group/sub-group" append tenantKey to each group
groups = [group for group in data["name"].split("/") if group]
appended_groups = [f"{tenant_key}-{group}" for group in groups]

data["name"] = "/".join(appended_groups)
name = data["name"].lstrip("/")
# Prefix the tenant_key to the main group
data["name"] = f"{tenant_key}-{name}"
current_app.logger.debug(f"Tenant group: {data['name']}")
group_servie = KeycloakGroupService()
return group_servie.create_group_role(data)
group_service = KeycloakGroupService()
return group_service.create_group_role(data)

def add_user_to_group_role(self, user_id: str, group_id: str, payload: Dict):
"""Add user to role."""
Expand Down

0 comments on commit 90c7a35

Please sign in to comment.