Fix orchestration actor role normalization at HTTP boundary
Deploy Canina / deploy (push) Successful in 4m50s
Deploy Canina / deploy (push) Successful in 4m50s
This commit is contained in:
1 parent
ba0aa5ee4e
commit
6ba2c51403
2 files changed
+41
-2
No files matched your search
@@ -97,13 +97,20 @@ export class OrchestrationController {
|
||||
) {}
|
||||
private actor(req: any): WorkflowIdentity {
|
||||
const id = req?.user?.id ?? req?.user?.sub;
|
||||
// Match RolesGuard aliases without promoting an admin to a reviewer.
|
||||
const normalized = typeof req?.user?.role === 'string'
|
||||
? req.user.role.toLowerCase().replace(/[_-]/g, '')
|
||||
: '';
|
||||
const role = normalized === 'admin' ? 'Admin'
|
||||
: ['superadmin', 'adminsuper'].includes(normalized) ? 'SUPER_ADMIN'
|
||||
: undefined;
|
||||
if (
|
||||
typeof id !== 'string' ||
|
||||
!id ||
|
||||
!['Admin', 'SUPER_ADMIN'].includes(req?.user?.role)
|
||||
!role
|
||||
)
|
||||
throw new ForbiddenException('Authenticated workflow identity required');
|
||||
return { id, role: req.user.role };
|
||||
return { id, role };
|
||||
}
|
||||
private safe(row: any, req: any) {
|
||||
const view = project(row);
|
||||
|
||||
Reference in new issue
Block a user