Skip to content

feat: require a setup token to create the first user on a tunnel (#32324) - #32511

Merged
BobbyHo merged 2 commits into
release/2.29from
backport/32324-to-2.29
Nov 20, 2026
Merged

BobbyHo merged 2 commits into
release/2.29from
backport/32324-to-2.29

Conversation

@coder-backporter-app

@coder-backporter-app coder-backporter-app Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Backport of #32324

Original PR: #32324 — feat: require a setup token to create the first user on a tunnel
Merge commit: 88d3494
Requested by: @BobbyHo

The automatic cherry-pick had conflicts. They are resolved by hand; the server and CLI changes are the same as in #32324.

Differences from #32324
  • scripts/develop does not exist on this branch, so those changes are left out. scripts/develop.sh always passes an access URL, so it does not open a tunnel.
  • Docs: the quickstart (docs/tutorials/quickstart.md), Azure and Compute Engine wording is applied to this branch's page layout. The sentences for docs/install/index.md and the RPM page are left out because those pages do not mention the tunnel here.
  • Generated API docs, CLI docs and typesGenerated.ts are regenerated with this branch's generators. This branch has no configuration reference page.
  • Setup page: the token field uses this branch's MUI TextField form, with the same validation, submit behaviour and hidden GitHub button. The test file is SetupPage.jest.tsx.
  • cli/login_test.go: the prompt test uses ptytest, because testutil/expecter is not on this branch.
  • codersdk and coderdtest.Options keep this branch's fields and add the setup token entries.

@coder-backporter-app coder-backporter-app Bot added the backport/v2.29 Backport PR targeting release/2.29 label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @coder-backporter-app[bot]!

This PR is targeting the release/2.29 release branch, but its title does not start with fix: or fix(scope):.

Only bug fixes should be cherry-picked to release branches. If this is a bug fix, please update the PR title to match the conventional commit format:

fix: description of the bug fix
fix(scope): description of the bug fix

If this is not a bug fix, it likely should not target a release branch.

)

fix(security): require setup token for first user on tunnels

Prevent unauthorized users from claiming Owner access on public `try.coder.app` tunnels before initial setup.

- Generate a setup token at startup when using a tunnel with no existing users.
- Require the token for first-user creation via the API, web UI, and CLI.
- Block GitHub/OIDC first-user signup until setup is complete.
- Support custom tokens via `--setup-token` / `CODER_SETUP_TOKEN` and non-interactive CLI setup.
- Update development scripts, documentation, and tests.
- Preserve existing behavior for deployments with an access URL or existing users.

Validated with automated tests and 23/23 manual scenarios using a real tunnel.

Refs CORE-784

(cherry picked from commit 88d3494)
@BobbyHo
BobbyHo force-pushed the backport/32324-to-2.29 branch from 0840108 to 15f202a Compare November 20, 2026 16:36
@BobbyHo BobbyHo changed the title feat: require a setup token to create the first user on a tunnel (#32324) (conflicts) feat: require a setup token to create the first user on a tunnel (#32324) Nov 20, 2026
@BobbyHo

BobbyHo commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

/coder-agents-review Please limit the review to P0, P1, and P2 issues only.

@coder-agents-review

coder-agents-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-11-20 18:28 UTC by @BobbyHo
Spend: $7.31 / $100.00

Review history
  • R1 (2026-11-20): 14 reviewers, 1 P2, COMMENT. Review

deep-review v0.13.0 | Round 1 | 7a9e112..27c1562

Last posted: Round 1, 1 findings (1 P2), COMMENT. Review

Finding inventory

Finding inventory: PR #32511

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Open cli/login.go:255 Non-TTY coder login without --first-user-setup-token on a tunnel fails with bare EOF R1 Leorio Yes
CRF-2 P4 Dropped by orchestrator (below P2; PR comment limits review to P0-P2) cli/setuptoken.go:17 setupTokenMinLength comment cites 142 bits; only length is checked R1 Gon P2 No
CRF-3 P4 Dropped by orchestrator (below P2; PR comment limits review to P0-P2) cli/login.go:253 Comment says setup token is asked first; username and name prompts come before it R1 Leorio No
CRF-4 P4 Dropped by orchestrator (below P2; PR comment limits review to P0-P2) cli/login.go:483 Flag description says server prints token; not true when set with --setup-token R1 Leorio No
CRF-5 Nit Dropped by orchestrator (below P2; PR comment limits review to P0-P2) docs/install/cloud/azure-vm.md:93 Rewritten line keeps typo "save use email" R1 Leorio No
CRF-6 Nit Dropped by orchestrator (below P2; PR comment limits review to P0-P2) cli/setuptoken_internal_test.go:149 ptrInt64 helper duplicates new(expr) R1 Ging-Go No
CRF-7 Note Dropped by orchestrator (below P2; PR comment limits review to P0-P2) site/src/pages/SetupPage/SetupPageView.stories.tsx:41 Test gaps below P2: SetupTokenRefused play asserts nothing, empty-token validation untested, GitHub button hiding untested R1 Bisky No
CRF-8 Note Dropped by orchestrator (no change asked) site/src/pages/SetupPage/SetupPageView.tsx:118 Setup page matches #32324 and handles its states R1 Nami No
CRF-9 Note Dropped by orchestrator (no change asked) cli/setuptoken.go:37 Ignored-flag warning and OAuth refusal messages name state and next step R1 Leorio No

Contested and acknowledged

None.

Law analysis

Not run. Effective additions 733, below the 1000 threshold.

Round log

Round 1

Full panel (round 1). Netero first pass: no findings, panel proceeds. Panel of 14: specialists ging-go, ging-ts, ging-react, kurapika, luffy, melody, nami, ryosuke (triggered by Go, TS, TSX, auth endpoints, new config flags, new JSON fields); core pariston, mafuuu; pool bisky (tests changed), gon and leorio (once-per-PR floor); wildcard razor (random from distilled set). Size exceeds the 9-12 target because 8 specialists were triggered.

PR comment from @BobbyHo limits the review to P0, P1, and P2. Findings below P2 are recorded here and not posted.

CRF-1 kept at P2. Keep-argument: a fully flagged script that worked before the change now fails on a tunnel with an error that names neither the token nor the flag; the username branch at cli/login.go:230 already gives a named non-interactive error, so the codebase treats this message as required. Downward case considered: affects only tunnel deployments with no user created by script, and email and password prompts have the same EOF behavior when their flags are missing. Keep-argument is stronger because this PR adds a new required input to a path that previously completed with the existing flags.

CRF-2 downgraded from P2 to P4. Keep-argument: a maintainer could read the comment as a guarantee that any accepted token carries about 142 bits. Downgrade reason: the comment states the capacity of 24 random letters and digits, which is accurate (log2(62^24) is about 142.9); it makes no claim about enforcement, has no runtime effect, and the generated token is 32 characters. Below the requested P0-P2 limit after downgrade.

Netero, Ryosuke, Melody verified the production Go is identical to merge commit 88d3494 apart from alignment and the declared ptytest test rewrite. All new tests pass at head per Netero, Bisky, Melody, Ryosuke, Pariston, Nami.

1 P2 posted. Reviewed against 7a9e112..27c1562.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR backports the setup token requirement for creating the first user on a try.coder.app tunnel to release/2.29. The production Go code matches #32324 apart from formatting and the declared test rewrite, and the new tests pass at this head. 1 P2. Items below P2 are left out, as the PR comment asked.

🤖 This review was automatically generated with Coder Agents.

Comment thread cli/login.go Resolved
@BobbyHo
BobbyHo merged commit 0029781 into release/2.29 Nov 20, 2026
30 checks passed
@BobbyHo
BobbyHo deleted the backport/32324-to-2.29 branch November 20, 2026 21:26

This branch had an error being deployed

1 failed deployment
docs-preview — 27c1562f Deployed Nov 20, 2026 by BobbyHo via cleanup #318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.29 Backport PR targeting release/2.29

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants