Skip to content

Commit 795bb4f

Browse files
committed
removed unwanted comments and updated unautorized response
1 parent b61c77a commit 795bb4f

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

extensions/m8flow-backend/src/m8flow_backend/api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ paths:
276276

277277
put:
278278
summary: Update tenant display name
279-
description: Updates the tenant's human-readable name in both the local database and the Keycloak realm (displayName). Restricted to 'super-admin' role. The slug and ID are immutable and cannot be changed.
279+
description: Updates the tenant's human-readable name in both the local database and the Keycloak realm (displayName). The slug and ID are immutable and cannot be changed.
280280
operationId: m8flow_backend.routes.keycloak_controller.update_tenant_name
281281
tags:
282282
- Tenant

extensions/m8flow-backend/src/m8flow_backend/routes/keycloak_controller.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,11 @@ def delete_tenant_realm(realm_id: str) -> tuple[dict, int]:
210210

211211
@handle_api_errors
212212
def update_tenant_name(tenant_id: str, body: dict) -> tuple[dict, int]:
213-
"""Update a tenant's name in both Keycloak (displayName) and Postgres.
214-
Restricted to super-admin role. Uses internal master admin token.
215-
"""
213+
"""Update a tenant's display name. Requires appropriate permissions."""
216214
user = getattr(g, 'user', None)
217215
if not user:
218216
raise ApiError(error_code="not_authenticated", message="User not authenticated", status_code=401)
219217

220-
# Check for super-admin permission via m8flow.yml configuration
221218
is_authorized = AuthorizationService.user_has_permission(user, "update", request.path)
222219

223220
if not is_authorized:
@@ -227,7 +224,7 @@ def update_tenant_name(tenant_id: str, body: dict) -> tuple[dict, int]:
227224
[getattr(g, 'identifier', g.name) for g in getattr(user, 'groups', [])],
228225
tenant_id
229226
)
230-
raise ApiError(error_code="forbidden", message="Only super-admin can update tenant name", status_code=403)
227+
raise ApiError(error_code="forbidden", message="Not authorized to update the tenant name.", status_code=403)
231228

232229
new_name = body.get("name")
233230
if not new_name or not str(new_name).strip():
@@ -243,13 +240,9 @@ def update_tenant_name(tenant_id: str, body: dict) -> tuple[dict, int]:
243240
if not tenant:
244241
return {"detail": "Tenant not found"}, 404
245242

246-
# Fetch Keycloak admin token internally
247243
admin_token = get_master_admin_token()
248244

249-
# Update Keycloak realm displayName
250245
update_realm(tenant.slug, display_name=new_name, admin_token=admin_token)
251-
252-
# Update Postgres tenant name
253246
tenant.name = new_name
254247
db.session.commit()
255248
logger.info("Updated tenant name: id=%s slug=%s to name=%s (updated by %s)",

0 commit comments

Comments
 (0)