Skip to content

fix: allow users with view-only permissions to execute workflows#19057

Open
vijaygovindaraja wants to merge 1 commit intotwentyhq:mainfrom
vijaygovindaraja:fix/15231-workflow-view-only-permissions
Open

fix: allow users with view-only permissions to execute workflows#19057
vijaygovindaraja wants to merge 1 commit intotwentyhq:mainfrom
vijaygovindaraja:fix/15231-workflow-view-only-permissions

Conversation

@vijaygovindaraja
Copy link
Copy Markdown

Summary

Users with view-only permissions for workflows cannot trigger active workflows (#15231). The SettingsPermissionGuard(PermissionFlagType.WORKFLOWS) was applied at the class level on WorkflowTriggerResolver, requiring "manage workflow" permission for ALL mutations — including runWorkflowVersion.

Fix

Move the WORKFLOWS permission guard from class-level to method-level on the three management mutations. runWorkflowVersion now only requires authentication (WorkspaceAuthGuard + UserAuthGuard).

Before: Class-level guard blocks all mutations for view-only users

@UseGuards(
  WorkspaceAuthGuard,
  UserAuthGuard,
  SettingsPermissionGuard(PermissionFlagType.WORKFLOWS), // blocks everything
)
export class WorkflowTriggerResolver { ... }

After: Method-level guards on management mutations only

@UseGuards(WorkspaceAuthGuard, UserAuthGuard) // auth only at class level

@UseGuards(SettingsPermissionGuard(PermissionFlagType.WORKFLOWS))
async activateWorkflowVersion() { ... }  // manage permission required

@UseGuards(SettingsPermissionGuard(PermissionFlagType.WORKFLOWS))
async deactivateWorkflowVersion() { ... } // manage permission required

async runWorkflowVersion() { ... }        // any authenticated user

@UseGuards(SettingsPermissionGuard(PermissionFlagType.WORKFLOWS))
async stopWorkflowRun() { ... }           // manage permission required

Permission model after this change

Mutation Permission required
activateWorkflowVersion WORKFLOWS (manage)
deactivateWorkflowVersion WORKFLOWS (manage)
stopWorkflowRun WORKFLOWS (manage)
runWorkflowVersion Authentication only (view access)

Fixes #15231

The SettingsPermissionGuard for WORKFLOWS was applied at the class
level on WorkflowTriggerResolver, requiring the "manage workflow"
settings permission for ALL mutations — including runWorkflowVersion.
This prevented users with view-only access from executing active
workflows they could see.

Move the WORKFLOWS permission guard from class-level to method-level
on the three management mutations (activateWorkflowVersion,
deactivateWorkflowVersion, stopWorkflowRun). The runWorkflowVersion
mutation now only requires WorkspaceAuthGuard + UserAuthGuard,
allowing any authenticated workspace member to trigger workflows
they have view access to.

Permission model after this change:
- activateWorkflowVersion: requires WORKFLOWS settings permission
- deactivateWorkflowVersion: requires WORKFLOWS settings permission
- stopWorkflowRun: requires WORKFLOWS settings permission
- runWorkflowVersion: requires authentication only (view access)

Fixes twentyhq#15231

Signed-off-by: V Govindarajan <vijay.govindarajan91@gmail.com>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions
Copy link
Copy Markdown
Contributor

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against 325d83b

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Users with view-only permissions cannot use workflows

1 participant