
Félix MalfaitandGitHub
9a80164cf3
Add comprehensive permission guard coverage across GraphQL and REST endpoints (#15739)
This PR enhances our security model by ensuring all GraphQL resolvers
and REST API endpoints have appropriate permission guards.
## Changes
### ESLint Rules
- Enhanced `graphql-resolvers-should-be-guarded` to require permission
guards on all resolvers (Query, Mutation, Subscription), not just
mutations
- Enhanced `rest-api-methods-should-be-guarded` to require permission
guards on all REST endpoints (GET, POST, PUT, PATCH, DELETE), not just
mutating methods
- Both rules now enforce consistent security: authentication guards +
permission guards for all endpoints
### Permission Guards Added
**Public Endpoints** - Added `NoPermissionGuard`:
- Auth-related queries (checkUserExists, findWorkspaceFromInviteHash,
validatePasswordResetToken)
- Billing webhooks (Stripe callbacks)
- SSO callbacks (SAML authentication)
- Workflow webhooks
- Cloudflare webhooks
- Route trigger endpoints
- GraphQL subscriptions
- Current workspace queries
- Geo-map address autocomplete
- View-related read operations (view-field, view-filter, view-group,
view-sort, view-filter-group)
**Settings Permission Guards** - Added `SettingsPermissionGuard`:
- API Keys management: `PermissionFlagType.API_KEYS_AND_WEBHOOKS`
- Webhooks management: `PermissionFlagType.API_KEYS_AND_WEBHOOKS`
- Page Layouts (write operations): `PermissionFlagType.LAYOUTS`
- REST Metadata API: `PermissionFlagType.DATA_MODEL`
- Agent operations: `PermissionFlagType.AI`
- Remote servers: `PermissionFlagType.DATA_MODEL`
- Remote tables: `PermissionFlagType.DATA_MODEL`
- Serverless functions: `PermissionFlagType.WORKFLOWS`
**Custom Permission Guards** - Added `CustomPermissionGuard`:
- REST Core API (permissions checked at query execution layer)
- Timeline calendar events (permission checks in service layer)
- Timeline messaging (permission checks in service layer)
- Search operations (permission checks in service layer)
- View operations (permission checks via dedicated view permission
guards)
### View Permission Guards
- Created dedicated `FindManyViewsPermissionGuard` and
`FindOneViewPermissionGuard` for reading views
- Created `CreateViewPermissionGuard` for view creation with
visibility-based permission checks
- All view child entities (view-field, view-filter, view-sort,
view-group, view-filter-group) use `NoPermissionGuard` for reads
- Write operations on view child entities use dedicated permission
guards that check parent view access
### Page Layout Permissions
- Read operations (GET/Query) now use `NoPermissionGuard` - users can
view layouts without LAYOUTS permission
- Write operations (POST/PATCH/DELETE/Mutation) require
`SettingsPermissionGuard(PermissionFlagType.LAYOUTS)`
- Applied consistently across page-layout, page-layout-tab, and
page-layout-widget endpoints
## Security Model
All endpoints now follow a consistent pattern:
1. **Authentication**: `UserAuthGuard`, `WorkspaceAuthGuard`, or
`PublicEndpointGuard`
2. **Authorization**: One of:
- `SettingsPermissionGuard(PermissionFlagType.XXX)` - for settings/admin
operations
- `CustomPermissionGuard` - when permissions are checked in service/data
layer
- `NoPermissionGuard` - for public or non-sensitive read operations
The ESLint rules automatically enforce this pattern going forward.
## Stats
- 47 files changed
- 603 insertions, 163 deletions
- 3 new guard files created
2025-11-10 12:17:38 +01:00
..
2025-07-23 13:43:27 +02:00
2025-11-03 14:57:37 +01:00
2025-11-07 18:22:28 +01:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-10-29 19:08:44 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 15:37:17 +01:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-08-08 09:04:45 +02:00
2025-10-03 17:22:03 +02:00
2025-11-10 12:17:38 +01:00
2025-10-09 18:17:32 +02:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-08-08 09:04:45 +02:00
2025-10-22 09:55:20 +02:00
2025-11-05 15:16:26 +00:00
2025-10-21 16:02:50 +02:00
2025-11-07 15:37:17 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 15:54:13 +01:00
2025-11-01 20:03:41 +01:00
2025-11-04 16:29:08 +01:00
2025-11-10 12:17:38 +01:00
2025-10-21 16:02:50 +02:00
2025-11-10 12:17:38 +01:00
2025-10-27 09:44:41 +01:00
2025-10-21 16:53:48 +02:00
2025-11-10 12:17:38 +01:00
2025-11-08 07:48:39 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 15:37:17 +01:00
2025-10-21 11:38:49 +02:00
2025-10-29 19:08:44 +01:00
2025-11-07 18:22:28 +01:00
2025-10-02 16:07:34 +00:00
2025-10-22 09:55:20 +02:00
2025-11-10 12:17:38 +01:00
2025-10-28 19:15:18 +01:00
2025-11-07 15:37:17 +01:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-11-07 18:22:28 +01:00
2025-11-07 18:22:28 +01:00
2025-11-08 14:32:06 +01:00
2025-10-15 17:41:14 +05:30
2025-10-09 18:17:32 +02:00
2025-10-02 19:14:12 +02:00
2025-11-10 12:17:38 +01:00
2025-11-05 12:43:23 +00:00
2025-10-02 18:36:52 +02:00
2025-11-07 18:22:28 +01:00
2025-04-09 14:11:26 +02:00
2025-11-06 17:47:27 +01:00
2025-10-31 17:46:58 +01:00
2025-11-06 17:47:27 +01:00
2025-11-07 15:37:17 +01:00
2025-11-07 15:37:17 +01:00
2025-11-06 18:29:12 +00:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-11-10 12:17:38 +01:00
2025-11-07 18:22:28 +01:00
2025-10-14 18:49:40 +02:00