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:
Félix Malfait
2025-11-07 15:37:17 +01:00
committed by GitHub
parent 44d6ec2594
commit cff17db6cb
306 changed files with 13863 additions and 976 deletions
@@ -44,7 +44,7 @@ export const WorkflowStepFooter = ({
dropdownId={dropdownId}
data-select-disable
clickableComponent={
<Button title="Options" hotkeys={[getOsControlSymbol(), 'O']} />
<Button title={t`Options`} hotkeys={[getOsControlSymbol(), 'O']} />
}
dropdownPlacement="top-end"
dropdownOffset={{ y: parseInt(theme.spacing(2), 10) }}
@@ -99,7 +99,7 @@ export const WorkflowStepFooter = ({
const deleteButton = (
<Button
title="Delete"
title={t`Delete`}
onClick={() => {
deleteStep(stepId);
}}
@@ -500,7 +500,7 @@ export const WorkflowEditActionServerlessFunction = ({
activeTabId === WorkflowServerlessFunctionTabId.TEST
? [
<CmdEnterActionButton
title="Test"
title={t`Test`}
onClick={handleRunFunction}
disabled={isTesting}
/>,
@@ -153,8 +153,8 @@ export const WorkflowFindRecordsSorts = ({
variant="secondary"
accent="default"
onClick={handleAddSort}
ariaLabel="Add sort"
title="Add sort"
ariaLabel={t`Add sort`}
title={t`Add sort`}
disabled={readonly}
/>
</StyledAddButtonContainer>
@@ -15,6 +15,7 @@ import { useSubmitFormStep } from '@/workflow/workflow-steps/workflow-actions/fo
import { type WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';
import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';
import { useWorkflowActionHeader } from '@/workflow/workflow-steps/workflow-actions/hooks/useWorkflowActionHeader';
import { useLingui } from '@lingui/react/macro';
import { useEffect, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/display';
@@ -33,6 +34,7 @@ export const WorkflowEditActionFormFiller = ({
action,
actionOptions,
}: WorkflowEditActionFormFillerProps) => {
const { t } = useLingui();
const { getIcon } = useIcons();
const { submitFormStep } = useSubmitFormStep();
const [formData, setFormData] = useState<FormData>(action.settings.input);
@@ -201,7 +203,7 @@ export const WorkflowEditActionFormFiller = ({
<RightDrawerFooter
actions={[
<CmdEnterActionButton
title="Submit"
title={t`Submit`}
onClick={onSubmit}
disabled={!canSubmit}
/>,
@@ -18,6 +18,7 @@ import { isMethodWithBody } from '@/workflow/workflow-steps/workflow-actions/htt
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useLingui } from '@lingui/react/macro';
import { useEffect } from 'react';
import { IconPlayerPlay, IconSettings, useIcons } from 'twenty-ui/display';
import {
@@ -90,6 +91,7 @@ export const WorkflowEditActionHttpRequest = ({
action,
actionOptions,
}: WorkflowEditActionHttpRequestProps) => {
const { t } = useLingui();
const theme = useTheme();
const { getIcon } = useIcons();
const activeTabId = useRecoilComponentValue(
@@ -229,7 +231,7 @@ export const WorkflowEditActionHttpRequest = ({
activeTabId === WorkflowHttpRequestTabId.TEST
? [
<CmdEnterActionButton
title="Test"
title={t`Test`}
onClick={handleTestRequest}
disabled={isTesting}
/>,