Enhance role-check system with stricter checks (#15392)
## Overview This PR strengthens our permission system by introducing more granular role-based access control across the platform. ## Changes ### New Permissions Added - **Applications** - Control who can install and manage applications - **Layouts** - Control who can customize page layouts and UI structure - **AI** - Control access to AI features and agents - **Upload File** - Separate permission for file uploads - **Download File** - Separate permission for file downloads (frontend visibility) ### Security Enhancements - Implemented whitelist-based validation for workspace field updates - Added explicit permission guards to core entity resolvers - Enhanced ESLint rule to enforce permission checks on all mutations - Created `CustomPermissionGuard` and `NoPermissionGuard` for better code documentation ### Affected Components - Core entity resolvers: webhooks, files, domains, applications, layouts, postgres credentials - Workspace update mutations now use whitelist validation - Settings UI updated with new permission controls ### Developer Experience - ESLint now catches missing permission guards during development - Explicit guard markers make permission requirements clear in code review - Comprehensive test coverage for new permission logic ## Testing - ✅ All TypeScript type checks pass - ✅ ESLint validation passes - ✅ New permission guards properly enforced - ✅ Frontend UI displays new permissions correctly ## Migration Notes Existing workspaces will need to assign the new permissions to roles as needed. By default, all new permissions are set to `false` for non-admin roles.
This commit is contained in:
@@ -18,6 +18,8 @@ export class ViewException extends CustomException {
|
||||
export enum ViewExceptionCode {
|
||||
VIEW_NOT_FOUND = 'VIEW_NOT_FOUND',
|
||||
INVALID_VIEW_DATA = 'INVALID_VIEW_DATA',
|
||||
VIEW_CREATE_PERMISSION_DENIED = 'VIEW_CREATE_PERMISSION_DENIED',
|
||||
VIEW_MODIFY_PERMISSION_DENIED = 'VIEW_MODIFY_PERMISSION_DENIED',
|
||||
}
|
||||
|
||||
export enum ViewExceptionMessageKey {
|
||||
@@ -25,6 +27,8 @@ export enum ViewExceptionMessageKey {
|
||||
OBJECT_METADATA_ID_REQUIRED = 'OBJECT_METADATA_ID_REQUIRED',
|
||||
VIEW_NOT_FOUND = 'VIEW_NOT_FOUND',
|
||||
INVALID_VIEW_DATA = 'INVALID_VIEW_DATA',
|
||||
VIEW_CREATE_PERMISSION_DENIED = 'VIEW_CREATE_PERMISSION_DENIED',
|
||||
VIEW_MODIFY_PERMISSION_DENIED = 'VIEW_MODIFY_PERMISSION_DENIED',
|
||||
}
|
||||
|
||||
export const generateViewExceptionMessage = (
|
||||
@@ -40,6 +44,10 @@ export const generateViewExceptionMessage = (
|
||||
return `View${id ? ` (id: ${id})` : ''} not found`;
|
||||
case ViewExceptionMessageKey.INVALID_VIEW_DATA:
|
||||
return `Invalid view data${id ? ` for view id: ${id}` : ''}`;
|
||||
case ViewExceptionMessageKey.VIEW_CREATE_PERMISSION_DENIED:
|
||||
return 'You do not have permission to create workspace-level views';
|
||||
case ViewExceptionMessageKey.VIEW_MODIFY_PERMISSION_DENIED:
|
||||
return 'You do not have permission to modify this view';
|
||||
default:
|
||||
assertUnreachable(key);
|
||||
}
|
||||
@@ -53,5 +61,9 @@ export const generateViewUserFriendlyExceptionMessage = (
|
||||
return msg`WorkspaceId is required to create a view.`;
|
||||
case ViewExceptionMessageKey.OBJECT_METADATA_ID_REQUIRED:
|
||||
return msg`ObjectMetadataId is required to create a view.`;
|
||||
case ViewExceptionMessageKey.VIEW_CREATE_PERMISSION_DENIED:
|
||||
return msg`You don't have permission to create workspace-level views.`;
|
||||
case ViewExceptionMessageKey.VIEW_MODIFY_PERMISSION_DENIED:
|
||||
return msg`You don't have permission to modify this view.`;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user