Skip to content

Commit 7cc8589

Browse files
fix(api,gateway): allow admins to access resources without tenant scope
Remove tenant and user ID headers from admin API requests to enable admins to view and manage resources across all namespaces from the admin dashboard. Update authorization middleware to permit admin access without tenant context.
1 parent ef098aa commit 7cc8589

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

api/routes/middleware/authorize.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ func Authorize(next echo.HandlerFunc) echo.HandlerFunc {
1515

1616
id := gateway.IDFromContext(ctx)
1717
tenant := gateway.TenantFromContext(ctx)
18-
if id != nil && tenant == nil {
18+
gCtx := c.(*gateway.Context)
19+
20+
// Allow admins to access resources without tenant scope (e.g., from /admin/api endpoints)
21+
if id != nil && tenant == nil && !gCtx.IsAdmin() {
1922
return c.NoContent(http.StatusForbidden)
2023
}
2124

gateway/nginx/conf.d/shellhub.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,8 @@ server {
336336
proxy_set_header X-Forwarded-Port $x_forwarded_port;
337337
proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
338338
proxy_set_header X-Api-Key $api_key;
339-
proxy_set_header X-ID $id;
340339
proxy_set_header X-Request-ID $request_id;
341340
proxy_set_header X-Role $role;
342-
proxy_set_header X-Tenant-ID $tenant_id;
343341
proxy_set_header X-Username $username;
344342
proxy_set_header X-Admin $admin;
345343

0 commit comments

Comments
 (0)