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).
20 lines
1.1 KiB
SQL
20 lines
1.1 KiB
SQL
ALTER TABLE templates ADD COLUMN browser_only boolean DEFAULT false NOT NULL;
|
|
|
|
COMMENT ON COLUMN templates.browser_only IS 'Whether coderd refuses non-browser client connections, such as SSH, port forwarding and desktop IDEs, to workspaces built from this template. The deployment-wide browser_only setting applies on top of this.';
|
|
|
|
DROP VIEW template_with_names;
|
|
|
|
CREATE VIEW template_with_names AS
|
|
SELECT templates.*,
|
|
COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url,
|
|
COALESCE(visible_users.username, ''::text) AS created_by_username,
|
|
COALESCE(visible_users.name, ''::text) AS created_by_name,
|
|
COALESCE(organizations.name, ''::text) AS organization_name,
|
|
COALESCE(organizations.display_name, ''::text) AS organization_display_name,
|
|
COALESCE(organizations.icon, ''::text) AS organization_icon
|
|
FROM ((templates
|
|
LEFT JOIN visible_users ON ((templates.created_by = visible_users.id)))
|
|
LEFT JOIN organizations ON ((templates.organization_id = organizations.id)));
|
|
|
|
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';
|