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:
+3
@@ -75,6 +75,9 @@ export class CompanyWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
label: msg`Domain Name`,
|
||||
description: msg`The company website URL. We use this url to fetch the company icon`,
|
||||
icon: 'IconLink',
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
})
|
||||
@WorkspaceIsUnique()
|
||||
domainName: LinksMetadata;
|
||||
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';
|
||||
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
|
||||
import { ChannelSyncResolver } from 'src/modules/connected-account/channel-sync/channel-sync.resolver';
|
||||
import { ChannelSyncService } from 'src/modules/connected-account/channel-sync/services/channel-sync.service';
|
||||
|
||||
@Module({
|
||||
imports: [WorkspaceDataSourceModule],
|
||||
imports: [PermissionsModule, WorkspaceDataSourceModule],
|
||||
providers: [ChannelSyncResolver, ChannelSyncService],
|
||||
exports: [ChannelSyncService],
|
||||
})
|
||||
|
||||
+3
@@ -6,7 +6,9 @@ import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filt
|
||||
import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
|
||||
import { SettingsPermissionsGuard } from 'src/engine/guards/settings-permissions.guard';
|
||||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
||||
import { PermissionFlagType } from 'src/engine/metadata-modules/permissions/constants/permission-flag-type.constants';
|
||||
import { ChannelSyncSuccessDTO } from 'src/modules/connected-account/channel-sync/dtos/channel-sync-success.dto';
|
||||
import { ChannelSyncService } from 'src/modules/connected-account/channel-sync/services/channel-sync.service';
|
||||
|
||||
@@ -18,6 +20,7 @@ export class ChannelSyncResolver {
|
||||
constructor(private readonly channelSyncService: ChannelSyncService) {}
|
||||
|
||||
@Mutation(() => ChannelSyncSuccessDTO)
|
||||
@UseGuards(SettingsPermissionsGuard(PermissionFlagType.CONNECTED_ACCOUNTS))
|
||||
async startChannelSync(
|
||||
@Args('connectedAccountId', { type: () => UUIDScalarType })
|
||||
connectedAccountId: string,
|
||||
|
||||
@@ -87,6 +87,9 @@ export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
label: msg`Emails`,
|
||||
description: msg`Contact’s Emails`,
|
||||
icon: 'IconMail',
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
})
|
||||
@WorkspaceIsUnique()
|
||||
emails: EmailsMetadata;
|
||||
@@ -136,6 +139,9 @@ export class PersonWorkspaceEntity extends BaseWorkspaceEntity {
|
||||
label: msg`Phones`,
|
||||
description: msg`Contact’s phone numbers`,
|
||||
icon: 'IconPhone',
|
||||
settings: {
|
||||
maxNumberOfValues: 1,
|
||||
},
|
||||
})
|
||||
phones: PhonesMetadata;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user