Skip to content

refactor: define session token link handlers once in codersdk - #31767

Open
dylanhuff-at-coder wants to merge 14 commits into
mainfrom
dylan/codersdk-session-token-handlers
Open

dylanhuff-at-coder wants to merge 14 commits into
mainfrom
dylan/codersdk-session-token-handlers

Conversation

@dylanhuff-at-coder

@dylanhuff-at-coder dylanhuff-at-coder commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #31721.

coder open app and the dashboard each kept their own copy of the deep-link handlers that may receive the session token. The shared test fixture from #31721 catches the two checks behaving differently, but only for links someone wrote a case for. Adding a new editor to just one list wouldn't fail any test, and that one-sided change is how the CLI gap #31721 fixes happened in the first place.

This moves the handlers into codersdk (VSCodeSessionTokenSchemes, VSCodeSessionTokenPaths, VSCodeCoderExtensionID and JetBrainsSessionTokenHandlers) and generates them into typesGenerated.ts, so cli/open.go and site/src/modules/apps/apps.ts both build their lists from one source. The hard-coded coder.coder-remote in the VS Code link builders now uses VSCodeCoderExtensionID too.

No behavior change. The 55 shared cases from #31721 pass unchanged against both sides. The codersdk constants come from @EhabY's #31261, which had the same idea.

Kept out of #31721 on purpose: the security fix needs to backport cleanly to every supported release, and a new codersdk API plus regenerated types would widen every backport. This one is main only.

🤖 Generated with Claude Code

dylanhuff-at-coder and others added 10 commits November 3, 2026 14:24
…en app

coder open app substituted $SESSION_TOKEN into every external app URL on a
top-level agent. It now applies the dashboard's trusted-link check: the link
must open a known Coder IDE handler whose url param is this deployment, and
the placeholder must be its token. Other links are printed with a warning
and not opened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…links

Strip one leading ? before parsing params, like URLSearchParams, so a
duplicate url can't hide behind it. Lowercase hosts as ASCII only and
reject non-ASCII hosts, since Unicode folding mapped hosts such as
codİng.com onto a trusted host that browsers resolve elsewhere. Narrow the
docs: the dashboard leaves http and https links enabled without a token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split params on & only so a ; in another value no longer rejects a link
the dashboard trusts, and compare ports numerically so :0443 matches the
default port. Out-of-range ports are rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oard

Move the trusted-link cases into sessionTokenDestinationCases.json and
run them from both cli/open_internal_test.go and apps.test.ts, so the
two checks can't drift apart without a test failing. Add a case that only
the decoded-view check rejects, and point apps.ts at the Go copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…served test host

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the deep-link handlers that may receive the session token into
codersdk and generate them into typesGenerated.ts, so coder open app and
the dashboard read one list instead of two hand-kept copies. Use
VSCodeCoderExtensionID for the hard-coded coder.coder-remote links.

Co-authored-by: Ehab Younes <ehab.alyounes@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as ready for review November 5, 2026 17:28
@dylanhuff-at-coder
dylanhuff-at-coder deleted the branch dylan/cli-open-app-trusted-token-links November 5, 2026 17:38
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
…n-token-handlers

# Conflicts:
#	cli/open.go
#	site/src/modules/apps/apps.ts
@dylanhuff-at-coder
dylanhuff-at-coder changed the base branch from dylan/cli-open-app-trusted-token-links to main November 5, 2026 17:39
@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as draft November 5, 2026 17:40
@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as ready for review November 9, 2026 21:23
@dylanhuff-at-coder
dylanhuff-at-coder temporarily deployed to main November 9, 2026 21:23 — with GitHub Actions Inactive
@ssncferreira
ssncferreira removed their request for review November 12, 2026 10:07
@SasSwart

Copy link
Copy Markdown
Collaborator

@dylanhuff-at-coder reviewing now.

This branch was previously deployed

1 inactive deployment
main — 80aad78f Deployed Nov 9, 2026 by dylanhuff-at-coder via cla #252851
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