Repository navigation
Conversation
CODER_BROWSER_ONLY refuses SSH, port forwarding and desktop IDE connections for a whole deployment, so a deployment that hosts both regulated and general-purpose templates cannot adopt it without taking those connections away from everyone. Add a browser_only setting on the template, enforced in coderd at the agent-scoped coordinate endpoint, per tunnel on the user-scoped tailnet endpoint, and on the MCP agent connection. The deployment-wide flag stays a global override. Enabling the setting requires the browser_only entitlement. Disabling it does not, and enforcement does not check the entitlement, so a lapsed license neither reopens the connections nor strands the template. Refs coder#29157
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
tarujg
marked this pull request as ready for review
September 11, 2026 00:32
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
cdrci2
added a commit
to coder/cla
that referenced
this pull request
Sep 11, 2026
…r-only # Conflicts: # docs/admin/security/audit-logs.md
…taruj/template-browser-only
BobbyHo
pushed a commit
that referenced
this pull request
Nov 18, 2026
Add per-template `browser_only` enforcement while preserving `CODER_BROWSER_ONLY` as a deployment-wide override. Refs #29157. Supersedes #29204 (closed by stale bot). Rebased onto current `main`, with migration renumbered to `000643`. ### Changes - Add `templates.browser_only` (default `false`) to the database, SDK, and template create/update APIs. - Require the `browser_only` entitlement to enable the setting, but allow disabling and continue enforcement after license expiry. - Reject agent coordinate connections with 409 and enforce per-template tunnel restrictions through `AuthorizeTunnel`. - Return non-fatal tunnel policy errors in both AGPL coordinator and pgcoord, preserving other active tunnels on shared connections. - Exclude browser-only workspaces from Desktop workspace updates and enforce the restriction in MCP agent connections. - Fix `TestMigration000617ConnectionLogsMethod` to use raw SQL, avoiding schema compatibility issues. ### Open questions - **Naming:** Keep `browser_only` or use `require_browser_connections`? - **Performance:** `AuthorizeTunnel` adds a database query under the coordinator mutex. Consider a narrower query if needed. - **Feature reporting:** Should the feature report as enabled when any template uses it? ### Out of scope Dashboard UI, CLI flag, and Terraform provider support (requires a separate `coder/terraform-provider-coderd` change). ### Verification - Relevant unit and integration tests passed, including coordinate rejection, tunnel isolation, workspace filtering, and non-fatal policy errors in both coordinators. - `golangci-lint` passed with no issues. - Regenerated database, SDK TypeScript, Swagger/API reference, and audit-log artifacts. - Not manually verified with Coder Desktop, multi-node deployments, workspace proxies, or UI. ### AI disclosure Most changes and the rebase were completed with Claude Code (Opus 5/5.5), following the [AI contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CODER_BROWSER_ONLYrefuses SSH, port forwarding and desktop IDE connections for a whole deployment, so a deployment that hosts both regulated and general-purpose templates can only adopt it by taking those connections away from everyone. This adds abrowser_onlysetting on the template, enforced in coderd, and leaves the deployment flag as a global override.Refs #29157
What it does
templates.browser_only(new column,falseby default) is surfaced asbrowser_onlyoncodersdk.Template,CreateTemplateRequestandUpdateTemplateMeta, modeled on theallow_workspace_renamessetting from #27558.Enabling it requires the
browser_onlyentitlement; disabling it does not, and enforcement never checks the entitlement. A lapsed license therefore neither silently reopens the connections nor strands a template with them refused. This mirrors howAGPLTemplateAccessControlStorekeeps honoring an existingdeprecatedmessage that AGPL cannot set.FeatureBrowserOnly.Enabledtracks the deployment flag rather than the license, so the write gate usesEntitlement.Entitled().Enforcement
Every place the deployment flag already covers:
/api/v2/workspaceagents/{workspaceagent}/coordinatereturns 409 with the same shape as the deployment-wide handler./api/v2/tailnetis user-scoped and spans templates, so it cannot be refused as a whole. It is refused per tunnel inrbacAuthorizer.AuthorizeTunnel.tailnet.TunnelPolicyErrorcarries the reason past the generic "not found or you do not have permission" mask so the coordinator logs the real cause.Things I would like direction on
browser_onlyfor parity withCODER_BROWSER_ONLY. On a template,require_browser_connectionsmight read better./api/v2/tailnetdrops the whole peer. AnAuthorizeTunnelerror makes the coordinator tear down the connection, which is what already happens for an RBAC denial. Coder Desktop keeps one session for every workspace, so touching a browser-only workspace will drop and reconnect the session rather than just failing that tunnel. Pre-existing behavior, but this makes it much easier to hit.AuthorizeTunnelruns whilecore.mutexis held, and this adds a second round trip (GetTemplateByID, which reads thetemplate_with_namesview). I have not measured it. If it matters, a narrowSELECT browser_only FROM templates WHERE id = $1would replace the join.enterprise/coderd/coderd.go.Not included
coder templates editflag.coder/terraform-provider-coderd.Verification
Not verified: a multi-node deployment, the enterprise
pgcoordpath (covered only through the sharedCoordinateeAuthcode, not by a test), workspace proxies, and any UI.Local runs on darwin/arm64 against Postgres in Docker, Go 1.26.5:
TestBlockNonBrowserTemplate/AgentCoordinatedials the agent as the owner before and after flipping the template, so the refusal cannot be an RBAC denial. From that run's coderd log, fields trimmed for width:TestBlockNonBrowserTemplate/UserTailnetsends anAddTunnelon/api/v2/tailnetand asserts the 403 tunnel entry in the connection log. The coordinator logs the reason:make genwas run for the database,codersdktypescript, swagger and audit-log targets. The protobuf targets were skipped: nothing in this change touches.protofiles andprotoc-gen-gowas not available locally.AI disclosure
Most of this PR was written by Claude Code (Opus 5), so it falls under the AI contribution guidelines. The command output above is verbatim from those runs. Opening as a draft so I can review it before it reaches maintainers.