Skip to content

fix(site): gate template routes and actions by permissions - #31948

Merged
jakehwll merged 2 commits into
mainfrom
fix-template-permission-gates
Nov 17, 2026
Merged

jakehwll merged 2 commits into
mainfrom
fix-template-permission-gates

Conversation

@jakehwll

@jakehwll jakehwll commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

Template pages could be opened directly without the permissions their forms and API requests require, leading to rejected requests or endless loaders. Gate the routes and restricted queries before mounting editor controls, while preserving version metadata and read-only parameters for template readers.

Route Permission behavior
/templates/new Requires template-create permission before mounting the upload form.
/templates/new?exampleId=<starter-id> Requires template-create permission before mounting starter import.
/templates/new?fromTemplate=<template-id> Requires template-create permission and update permission on the source template before loading its version or variables. Duplication uses the permitted destination organization selected in the form.
/templates/new/builder and ?base=<base-id> Requires template-create permission. Denied deep links show the permission dialog; a disabled builder redirects to /templates/new.
/starter-templates Requires template-create permission before loading the creation gallery.
/starter-templates/<starter-id> Remains readable; hides Use template without template-create permission.
/templates/<template>/settings Requires update permission on the template.
/templates/<template>/settings/variables Requires template update before loading variables or mounting the form.
/templates/<template>/settings/schedule Requires template update before mounting scheduling controls.
/templates/<template>/settings/permissions Requires template update; loads the ACL only when template RBAC is enabled.
/templates/<template>/settings/parameters Preserves the existing read-only behavior for readers. The settings sidebar hides editor-only sections.
/templates/<template>/files Requires template update before requesting source files or comparisons.
/templates/<template>/prebuilds Requires template update and the enabled prebuilds feature before mounting invalidation controls.
/templates/<template>/versions/<version> Keeps version metadata available to readers, fetches source comparisons and offers Edit only with template update, and checks workspace-create permission for Create workspace.
/templates/<template>/versions/<version>/edit Requires template update before loading editor data or source files.

Template-specific routes also support /templates/<organization>/<template>/….

The template menu checks update, create, and delete separately: Duplicate requires source update and destination creation capability, while Delete uses resource-scoped deletion permission. Template browsing, the starter gallery, and the builder determine builder availability without fetching admin-only deployment configuration. Background query errors preserve loaded forms and editor content.

Validated with 76 affected unit tests, 15 browser story tests, Storybook visual inspection, pnpm format, pnpm check, pnpm lint, and the frontend self-reviews.

@jakehwll
jakehwll temporarily deployed to main November 10, 2026 04:38 — with GitHub Actions Inactive
@jakehwll
jakehwll temporarily deployed to main November 10, 2026 04:38 — with GitHub Actions Inactive
@jakehwll
jakehwll marked this pull request as ready for review November 10, 2026 04:39
@jakehwll
jakehwll temporarily deployed to main November 10, 2026 04:40 — with GitHub Actions Inactive
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T06:11:31.254555Z b564f81 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6098035002

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jakehwll
jakehwll temporarily deployed to main November 10, 2026 05:37 — with GitHub Actions Inactive
@jakehwll
jakehwll temporarily deployed to main November 10, 2026 05:45 — with GitHub Actions Inactive
@jakehwll

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b564f81d33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderagents

coderagents Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Blocking

  • docs/templates/creating-templates.md (open) - The create-template flows (/templates/new, /templates/new?exampleId=, /starter-templates, /templates/new/builder) are now gated on the createTemplates permission and show a "You don't have permission to view this page" dialog for users without it. The page says only "Users with the Template Administrator role or above can create templates within Coder." and never names the createTemplates permission or the dialog. (The role is "Template Admin", not "Template Administrator".) State who can create, that creating is gated on the createTemplates permission, and what a user without it sees.
  • docs/templates/creating-templates.md (open) - Duplicating a template now lets the user choose the destination organization and create the copy in a different organization than the source (cross-organization duplication). The "From an existing template" steps list only name, icon, and description, and never mention the organization selector or that Duplicate requires template update permission plus the permission to create templates.
Findings for agents
- id: learner-1
  persona: learner
  class: missing
  blocking: true
  file: docs/templates/creating-templates.md
  line: 5
  quote: "Users with the `Template Administrator` role or above can create templates within Coder."
  evidence:
    - site/src/pages/CreateTemplatePage/CreateTemplatePage.tsx:88
    - site/src/modules/permissions/templates.ts:10
  rule: null
  problem: Create-template routes are now gated on the createTemplates permission and show a permission dialog for users without it, but the page names only the coarse "Template Administrator role or above" (which is "Template Admin") and never explains the createTemplates permission or the dialog.
  fix: State that creating a template requires the createTemplates permission, granted by the Template Admin role or individually via RBAC, and that users without it see "You don't have permission to view this page". Use "Template Admin", not "Template Administrator".
  verified: true
- id: learner-4
  persona: learner
  class: missing
  blocking: true
  file: docs/templates/creating-templates.md
  line: 149
  quote: "Give the new template a name, icon, and description."
  evidence:
    - site/src/pages/CreateTemplatePage/DuplicateTemplateView.tsx:107
    - site/src/pages/CreateTemplatePage/DuplicateTemplateView.tsx:120
  rule: null
  problem: Duplicating a template now supports cross-organization duplication (the copy can target a different organization than the source, via an organization selector), and Duplicate requires template update permission plus the permission to create templates. The duplicate steps list only name, icon, and description and never mention the destination organization or the required permissions.
  fix: In the "From an existing template" Web UI steps, note that the duplication form includes an organization selector for the copy's destination (which can differ from the source) when organizations are enabled, and that Duplicate requires template update permission plus the permission to create templates.
  verified: true

Automated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong.

@jakehwll
jakehwll merged commit a3e2e8e into main Nov 17, 2026
30 of 31 checks passed
@jakehwll
jakehwll deleted the fix-template-permission-gates branch November 17, 2026 23:32
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
docs-preview — b564f81d Deployed Nov 17, 2026 by jakehwll via cleanup #189
main — b564f81d Deployed Nov 17, 2026 by jakehwll via cla #259033
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants