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:
+6
-4
@@ -1,5 +1,6 @@
|
||||
import { type MessageDescriptor } from '@lingui/core';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { assertUnreachable } from 'twenty-shared/utils';
|
||||
|
||||
import { CustomException } from 'src/utils/custom-exception';
|
||||
|
||||
@@ -17,6 +18,7 @@ export class ViewGroupException extends CustomException {
|
||||
export enum ViewGroupExceptionCode {
|
||||
VIEW_GROUP_NOT_FOUND = 'VIEW_GROUP_NOT_FOUND',
|
||||
INVALID_VIEW_GROUP_DATA = 'INVALID_VIEW_GROUP_DATA',
|
||||
VIEW_NOT_FOUND = 'VIEW_NOT_FOUND',
|
||||
}
|
||||
|
||||
export enum ViewGroupExceptionMessageKey {
|
||||
@@ -25,6 +27,7 @@ export enum ViewGroupExceptionMessageKey {
|
||||
VIEW_GROUP_NOT_FOUND = 'VIEW_GROUP_NOT_FOUND',
|
||||
INVALID_VIEW_GROUP_DATA = 'INVALID_VIEW_GROUP_DATA',
|
||||
FIELD_METADATA_ID_REQUIRED = 'FIELD_METADATA_ID_REQUIRED',
|
||||
VIEW_NOT_FOUND = 'VIEW_NOT_FOUND',
|
||||
}
|
||||
|
||||
export const generateViewGroupExceptionMessage = (
|
||||
@@ -42,8 +45,10 @@ export const generateViewGroupExceptionMessage = (
|
||||
return `Invalid view group data${id ? ` for view group id: ${id}` : ''}`;
|
||||
case ViewGroupExceptionMessageKey.FIELD_METADATA_ID_REQUIRED:
|
||||
return 'FieldMetadataId is required';
|
||||
case ViewGroupExceptionMessageKey.VIEW_NOT_FOUND:
|
||||
return `View${id ? ` (id: ${id})` : ''} not found`;
|
||||
default:
|
||||
return 'unknown';
|
||||
assertUnreachable(key);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,8 +62,5 @@ export const generateViewGroupUserFriendlyExceptionMessage = (
|
||||
return msg`ViewId is required to create a view group.`;
|
||||
case ViewGroupExceptionMessageKey.FIELD_METADATA_ID_REQUIRED:
|
||||
return msg`FieldMetadataId is required to create a view group.`;
|
||||
default: {
|
||||
return msg`unknown`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user