Skip to content

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

Open
BobbyHo wants to merge 7 commits into
bobby/core-784-generate-dev-passwordsfrom
bobby/core-784-setup-token
Open

BobbyHo wants to merge 7 commits into
bobby/core-784-generate-dev-passwordsfrom
bobby/core-784-setup-token

Conversation

@BobbyHo

@BobbyHo BobbyHo commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

When coder server starts without an access URL, it publishes itself on a public try.coder.app address. Until the first account exists, anyone who finds that address can open the setup page and make themselves the Owner. This PR closes that gap. On a tunnel with no users, the server now prints a setup token in its own output, and the first account can only be created by someone who enters that token. The setup page and coder login both ask for it. Deployments with an access URL are not changed.

Refs https://linear.app/codercom/issue/CORE-784

Note

This PR is stacked on #32283 and targets that branch, so the diff shows only this change. It will be rebased onto main after #32283 merges.

How to navigate this PR
  • About 300 lines of production code, 450 lines of tests, about 20 hand-written docs lines, and about 140 generated lines.
  • Read these closely, in this order:
    1. codersdk/users.go: the two new API fields, setup_token on the first-user request and setup_token_required on the auth methods response.
    2. codersdk/deployment.go: the new --setup-token server option. Check that it is marked secret and has no YAML key.
    3. coderd/setuptoken.go: the comparison and the two refusal responses. This is the most important file. Check that the comparison takes the same time for any input.
    4. coderd/users.go: the check in postFirstUser. Check its position, after the "user already exists" response and before password validation.
    5. coderd/userauth.go: the check in oauthLogin, which covers both GitHub and OIDC, and the new field in userAuthMethods.
    6. cli/setuptoken.go: resolveSetupToken decides whether this start needs a token and prints it. Check the four outcomes: access URL set, users exist, token supplied, token generated.
    7. cli/server.go: one call, placed directly above the "Logs will stream in below" line.
    8. cli/login.go: the new prompt and the --first-user-setup-token flag.
    9. site/src/pages/SetupPage/SetupPageView.tsx: the new field, the hidden GitHub button and the email hint.
    10. scripts/develop/main.go: scripts/develop.sh creates its own token, so that it can still create the admin user on a tunnel.
  • Skim the generated files: coderd/apidoc/docs.go, coderd/apidoc/swagger.json, site/src/api/typesGenerated.ts, everything under docs/reference/, docs/admin/setup/configuration-reference.md, and the --help golden files under cli/testdata/ and enterprise/cli/testdata/.
  • The only change that affects code outside this feature is the check in oauthLogin. It runs only when no user exists and a token is required.
Implementation

Server

  • coderd/coderd.go: new Options.SetupToken. An empty value means no token is required. It is set once at startup and never changes.
  • coderd/setuptoken.go (new): compares SHA-256 digests of the two tokens in constant time. A missing token and a wrong token get the same response.
  • coderd/users.go: postFirstUser returns 403 when a token is required and the request does not carry the right one.
  • coderd/userauth.go: oauthLogin refuses to create the first user when a token is required. userAuthMethods reports setup_token_required.
  • cli/setuptoken.go (new) and cli/server.go: the token is required only when the server opened a tunnel and the user count is 0. The token lives in memory and a new one is generated on each start.
  • codersdk/deployment.go: --setup-token and CODER_SETUP_TOKEN let an operator supply the token, for scripted installs. Minimum 24 characters.

Clients

  • cli/login.go: asks for the token before the email, so someone without it stops early. --first-user-setup-token and CODER_FIRST_USER_SETUP_TOKEN skip the prompt.
  • site/src/pages/SetupPage/SetupPageView.tsx: shows a "Setup token" field when the server requires one.
  • scripts/develop/main.go: when no access URL is passed, generates a token, gives it to the server through CODER_SETUP_TOKEN, and sends it when it creates the admin user.

Docs

  • docs/install/index.md, docs/install/server/rpm.md, docs/install/server/cloud/azure-vm.md, docs/install/server/cloud/compute-engine.md: a few sentences each, where the tunnel URL is introduced.
  • docs/get-started/index.md: Step 3 of the quickstart lists the setup token and no longer offers Continue with GitHub. The welcome-create-admin-user.png screenshot is not updated yet.

Choices a reviewer might question

  • OAuth sign-up of the first user is refused on a tunnel, and the GitHub button is hidden on the setup page. An OAuth redirect cannot carry the token. After the first account exists, GitHub sign-in works as before.
  • --setup-token is ignored, with a warning, when an access URL is set. The token is a tunnel-only protection. A silent no-op would let an operator believe the first user is protected. Requiring a supplied token with an access URL is a separate change, tracked in CORE-891, because it would also refuse an OAuth first user on deployments that have password sign-in disabled.
  • A supplied token is not printed back. A script that starts the server would copy it into its log.
  • setup_token_required is a field on the existing auth methods response, not a new endpoint. The setup page and coder login already call it.
  • The setup page uses a plain password-type field for the token, not the shared PasswordField component. That component sends its value to the password strength endpoint.
  • The option has no YAML key, like other secrets, so it has an entry in the exclusion list of TestDeploymentValues_HighlyConfigurable in codersdk/deployment_test.go.
  • The token is not stored in the database. A restart before setup prints a new one.
Expected Output
  • coder server with no access URL and no users prints Setup token: <32 letters and digits> and one line of instructions, directly above "Logs will stream in below".
  • Each start generates a different token.
  • With --setup-token or CODER_SETUP_TOKEN, the server uses that token and prints only that a token is needed and where it was set.
  • On a tunnel with no users, a supplied token shorter than 24 characters stops the server with --setup-token must be at least 24 characters. The length is not checked when the token is not used.
  • With an access URL set, no token is required. A supplied token is ignored, and a warning says so and names coder server create-admin-user.
  • When a user already exists, no token is printed or required.
  • POST /api/v2/users/first without the token, or with a wrong one, returns 403 with "A setup token is required to create the first user. Find it in the output of coder server." and a validation error on setup_token.
  • With the right token, the first user is created as before.
  • A request for the first user when one already exists still returns 409, with or without a token.
  • A GitHub or OIDC sign-in when no user exists and a token is required shows a "Setup is not complete" page and creates no user.
  • GET /api/v2/users/authmethods includes "setup_token_required": true only when a token is required.
  • The setup page shows a "Setup token" field, hides the GitHub button, and shows the server's refusal under the field when the token is wrong.
  • coder login asks "Setup token:" before the email. It does not ask when the flag or environment variable is set, or when the server requires no token.
  • scripts/develop.sh with no --access-url still creates its admin user without any manual step.
Testing
  • coderd/users_test.go, TestFirstUser/SetupToken: missing and wrong tokens are refused with 403, the right token creates the user, and the auth methods response reports the requirement.
  • coderd/userauth_test.go, SetupTokenBlocksFirstUser under TestUserOAuth2Github and TestUserOIDC: the OAuth sign-in is refused and no user is created.
  • cli/setuptoken_internal_test.go, TestResolveSetupToken: access URL set, users exist, supplied token, short token, a short token that is ignored, generated token, and two starts that produce different tokens.
  • cli/login_test.go, InitialUserSetupTokenPrompt and InitialUserSetupTokenFlag: the prompt appears and the flag skips it.
  • scripts/develop/main_test.go and scripts/develop/password_test.go: the token reaches the server's environment and the first-user request.
  • site/src/pages/SetupPage/SetupPage.test.tsx: the token is sent when required, and left out of the request when not.
  • site/src/pages/SetupPage/SetupPageView.stories.tsx: SetupTokenRequired and SetupTokenRefused.
  • Not covered by an automated test: the position of the token in the real coder server output, and the full flow through a real try.coder.app tunnel. Both were checked in the manual run. See Manual Test, scenarios 2 to 11.
  • Ran and passed: go test ./cli/... ./coderd/ ./codersdk/ ./scripts/develop/ ./enterprise/cli/ for the tests above and the help golden files, pnpm vitest run src/pages/SetupPage, the SetupPageView stories, pnpm lint:types, pnpm check, golangci-lint on the changed packages, and the docs lint. make pre-commit and the full test suite have not been run locally.
Manual Test

Run on 2026-11-17, 19:57 to 22:52 UTC, against this branch at 1b79d798f1. The run built the branch in a Linux development workspace and started throwaway coder server processes there, one at a time, each with its own config directory and built-in database, on a real try.coder.app tunnel. The browser steps were done on a laptop against the public tunnel URL, with a real GitHub account.

No setup token and no password was printed during the run. The helpers read a token from the server's log into a shell variable and print only its length and a short SHA-256 fingerprint. In the output below a token is shown as <token>, the tunnel address as https://<id>.pit-1.try.coder.app, and the email of the GitHub account is left out.

23 of 23 scenarios passed.

# Scenario Result
1 Environment: worktree, build, helpers Pass
2 A tunnel server with no users prints a setup token Pass
3 A client that is not signed in learns that a token is needed, and not the token Pass
4 A first-user request without the token is refused, from two networks Pass
5 Four wrong tokens get the same answer Pass
6 The token is checked before the password Pass
7 GitHub sign-in before setup is refused Pass
8 The setup page asks for the token and hides the GitHub button Pass
9 A wrong token on the setup page Pass
10 The right token on the setup page creates the Owner Pass
11 The first account switches to GitHub sign-in and signs in with it Pass
12 After setup the token does nothing Pass
13 A restart with a user prints no token and requires none Pass
14 A restart before setup gives a new token Pass
15 coder login asks for the token first Pass
16 coder login with --first-user-setup-token Pass
17 A supplied token that is too short stops a tunnel server Pass
18 A supplied token is used and is not shown Pass
19 With an access URL nothing changes Pass
20 ./scripts/develop.sh on a tunnel Pass
21 Docs and reference Pass
22 Unit tests on Linux Pass
23 Cleanup Pass

Facts worth knowing from the run:

  1. The same request gives the refusal and the acceptance. On one server, a first-user request without the token got 403 and created nobody (scenario 4). The same form with the token from the server's own output created the Owner (scenario 10). Between scenarios 9 and 10 only the token changed.
  2. There is no "before" server in this run. A server built from main on a tunnel can be taken over by anyone who finds its URL, so none was started. Scenario 19 shows the behaviour from before this PR on a loopback address: a request with no token gets 201.
  3. The switch to GitHub sign-in works on a real tunnel. The setup page hides the GitHub button while a token is required, and the hint under Email and two docs pages tell the user to switch under Account, then Security. Scenario 11 followed those words only. The path is right, GitHub is offered after a first user was created with a password, and the same user signs in with GitHub and is still Owner. No automated test covers a sign-in method change through the device flow.
  4. A machine keeps its tunnel URL across installs. This is on main. The server keeps its tunnel key in the user's config folder (~/.config/coderv2/devtunnel on Linux), not in the directory that --global-config names. Every server in this run got the same public URL, with a new database each time. So someone who learned the URL of an earlier trial knows the URL of the next one on the same machine before its operator opens it. That is the situation this PR is for.
  5. coder login ends on the first wrong setup token. An empty answer at Setup token: prints a sentence and asks again. A wrong answer is sent to the server, refused, and the command exits 1 (scenario 15). The operator has to run the command again. Not changed in this PR.
  6. A refused attempt leaves no line in the server log. The 403 answers of scenarios 4 to 6 and the refused GitHub sign-in of scenario 7 wrote nothing. An operator watching the log does not learn that someone tried.
  7. The server reports setup_token_required after the first user exists, until it restarts (scenarios 12 and 13). It has no effect. The setup page is not shown once a user exists, and three sign-ins happened while the field was still true.
  8. After a switch to GitHub sign-in the server fails to delete the old session. This is on main. In scenario 11 the server logged failed to delete old API key in convert to oidc with no authorization actor in context. The code is in coderd/userauth.go and is not part of this PR. The browser's cookie is cleared, but the old session stays in the database until it expires.
  9. An error line stands directly above the token on a new server. This is on main. Every start in this run printed [erro] embedded NATS pubsub is enabled but this replica has no cluster host and went on. On a tunnel server it is the third line above Setup token: (scenario 2).
  10. With ./scripts/develop.sh --skip-setup the token is one log line among many. develop wraps each line of the server in its own log format, and its large banner comes ten lines later (scenario 20). On a plain coder server the token stands alone above the logs line.
  11. The picture in the quickstart still shows the old form. docs/images/screenshots/welcome-create-admin-user.png has Email as the first field. A new picture with the "Setup token" field was taken in scenario 8 and is not in this PR yet.
  12. Two things about the workspace, not about the PR. It sets CODER_URL and CODER_SESSION_TOKEN for its own agent, and the CLI prefers those to the config directory, so one whoami check had to be run with both removed (scenario 16). And vitest ends there with three lines about a process that did not exit, which is not a test failure (scenario 22).
1. Environment
# workspace
mkdir -p ~/core784b/{logs,cfg,client,cache} && cd ~/coder
git fetch origin bobby/core-784-setup-token bobby/core-784-generate-dev-passwords
PR_HEAD=$(git rev-parse origin/bobby/core-784-setup-token); echo "PR head $PR_HEAD"
git worktree add --detach ~/core784b/src "$PR_HEAD"
git -C ~/core784b/src log --oneline origin/bobby/core-784-generate-dev-passwords..HEAD
env | grep -c '^CODER_ACCESS_URL=\|^CODER_SETUP_TOKEN=\|^CODER_FIRST_USER_'
cd ~/core784b/src && make -j build/coder_linux_amd64; echo "build exit $?"
./build/coder_linux_amd64 version | head -1
./build/coder_linux_amd64 server --help | grep -c -- '--setup-token'
( umask 077; head -c 48 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24 >~/core784b/pw )
stat -c '%a %s' ~/core784b/pw
PR head 1b79d798f1d61769aedeb7276c856b9ac8f4b3fe
1b79d798f1 Merge branch 'bobby/core-784-generate-dev-passwords' into bobby/core-784-setup-token
25e107b979 Merge branch 'bobby/core-784-generate-dev-passwords' into bobby/core-784-setup-token
f5a0da25d1 docs: say where the setup token is and how to switch to GitHub sign-in
9f4cd1db0c fix(cli): check the setup token length only when the token is used
50a720c558 fix(cli): keep the setup token code out of slim builds
5cc3a3fec1 feat: require a setup token to create the first user on a tunnel
0
build exit 0
Coder v2.39.0-devel+1b79d798f1
1
600 24

The helpers used below, all defined in one file in the workspace:

  • srv_start NAME [flags] starts coder server in the background with --global-config ~/core784b/cfg/NAME, --http-address 127.0.0.1:3400 and telemetry off, and writes its output to a new log file. srv_wait waits for the "Logs will stream in below" line or for the process to exit. srv_stop sends an interrupt and waits.
  • turl NAME prints the tunnel URL from the newest log. tok NAME reads the setup token from the newest log, and is only ever used as T=$(tok NAME).
  • tokinfo NAME prints the token's length, whether it is only letters and digits, a 12-character SHA-256 fingerprint, the number of log lines that contain the value and the number of Setup token: lines. It never prints the value. masked NAME prints the start-up output with the token replaced.
  • methods URL prints three fields of /api/v2/users/authmethods. hasuser URL prints the status of GET /api/v2/users/first, which is 404 while no user exists and 200 once one does.
  • post_first URL TOKEN [EMAIL] [PASSWORD] posts to /api/v2/users/first and prints the body and the status. A token of - sends no setup_token field. The password defaults to the random test password in ~/core784b/pw.

Servers are named t1 to t5. Only one runs at a time.

2. A tunnel server with no users prints a setup token
# workspace, a new config directory, no access URL
srv_start t1; srv_wait t1
masked t1
tokinfo t1
grep -c 'Opening tunnel' ~/core784b/logs/t1.log
started t1 pid 145471 log /home/coder/core784b/logs/t1.1.log at 20:10:06
t1 ready at 20:10:22
║               View the Web UI:                ║
║   https://<id>.pit-1.try.coder.app   ║
╚═══════════════════════════════════════════════╝
2026-11-17 20:10:21.767 [erro]  embedded NATS pubsub is enabled but this replica has no cluster host; set --cluster-host (CODER_CLUSTER_HOST) to this replica's routable IP address, or configure the DERP relay URL; falling back to PostgreSQL pubsub
2026-11-17 20:10:21.774 [info]  coderd: injecting default github external auth provider  type=github  client_id=Iv1.6a2b4b4aec4f4fe7  device_flow=true
2026-11-17 20:10:21.780 [info]  oauth2 provider disabled  flag=CODER_OAUTH2_PROVIDER_ENABLE
Setup token: <token>
The setup token is needed to create the first user. Enter it on the setup page, or when coder login asks for it.

==> Logs will stream in below (press ctrl+c to gracefully exit):
t1: len=32 alnum=yes fp=523d82fdf658 lines_with_token=1 token_lines=1
1

The token line is directly above the logs line, where an operator looks. It is 32 letters and digits, and the value is in exactly one line of the log. This server stayed up for scenarios 3 to 13.

3. A client that is not signed in learns that a token is needed, and not the token
# workspace, through the public URL
U=$(turl t1); T=$(tok t1)
curl -s "$U/api/v2/users/authmethods"; echo
hasuser "$U"
for p in /api/v2/users/authmethods /api/v2/users/first /api/v2/buildinfo /api/v2/ /setup /; do
  curl -s -o /tmp/body -w "$p -> %{http_code} %{size_download} bytes" "$U$p"
  echo " token_hits=$(grep -cF "$T" /tmp/body)"
done; rm -f /tmp/body
{"password":{"enabled":true},"github":{"enabled":true,"default_provider_configured":true},"oidc":{"enabled":false,"signInText":"","iconUrl":""},"setup_token_required":true}
first user check -> 404
/api/v2/users/authmethods -> 200 173 bytes token_hits=0
/api/v2/users/first -> 404 53 bytes token_hits=0
/api/v2/buildinfo -> 200 459 bytes token_hits=0
/api/v2/ -> 200 19 bytes token_hits=0
/setup -> 200 11117 bytes token_hits=0
/ -> 200 11117 bytes token_hits=0

The new field is a boolean. None of the six public responses contains the token, and the sizes show that the search was over real bodies.

4. A first-user request without the token is refused, from two networks
# workspace, through the public URL
post_first "$U" -
hasuser "$U"

# laptop, a different machine on a different network
curl -s -w '\n-> %{http_code}\n' -H 'Content-Type: application/json' \
  -d '{"email":"stranger@example.com","username":"stranger","password":"not-the-real-one-4Zq8"}' \
  "$U/api/v2/users/first"
curl -s -o /dev/null -w 'first user check from the laptop -> %{http_code}\n' "$U/api/v2/users/first"
{"message":"A setup token is required to create the first user. Find it in the output of coder server.","validations":[{"field":"setup_token","detail":"Missing or incorrect setup token."}]}

-> 403
first user check -> 404
{"message":"A setup token is required to create the first user. Find it in the output of coder server.","validations":[{"field":"setup_token","detail":"Missing or incorrect setup token."}]}

-> 403
first user check from the laptop -> 404

Both machines get the same body and no user exists afterwards. Before this PR this request made its sender the Owner.

5. Four wrong tokens get the same answer
# workspace
T=$(tok t1); last=${T: -1}; flip=$([ "$last" = a ] && echo b || echo a)
{ post_first "$U" ""                # an empty string
  post_first "$U" "short"           # the wrong length
  post_first "$U" "${T%?}$flip"     # the right length, last character changed
  post_first "$U" "$T$T"            # the token twice
} >/tmp/out
grep -v '^$' /tmp/out | sort | uniq -c
grep -cF "$T" /tmp/out
hasuser "$U"; rm -f /tmp/out
      4 -> 403
      4 {"message":"A setup token is required to create the first user. Find it in the output of coder server.","validations":[{"field":"setup_token","detail":"Missing or incorrect setup token."}]}
0
first user check -> 404

One body, four times, and it is the body of scenario 4. A missing token and a wrong token cannot be told apart, and no answer contains the real token. The third value differed from the real token in one byte.

6. The token is checked before the password
# workspace, t1: a token is required
post_first "$U" - stranger@example.com 'a'

# workspace, later, on a server with an access URL where no token is required (scenario 19)
post_first http://127.0.0.1:3400 - plain@example.com 'a'
{"message":"A setup token is required to create the first user. Find it in the output of coder server.","validations":[{"field":"setup_token","detail":"Missing or incorrect setup token."}]}

-> 403
{"message":"Password is invalid","validations":[{"field":"password","detail":"insecure password, try including more special characters, using uppercase letters, using numbers or using a longer password"}]}

-> 400

The same request with the password a gets 400 where no token is required, and 403 with no word about the password where one is. A stranger without the token learns nothing about the other rules.

7. GitHub sign-in before setup is refused
# workspace
hasuser "$U"
echo "$U/api/v2/users/oauth2/github/callback"
# browser: open the printed URL, enter the one-time code on GitHub's device page, approve
hasuser "$U"
first user check -> 404
first user check -> 404

The callback URL sent the browser to /login/device, which showed a one-time code. After GitHub approved, the page kept its code and link and showed this in an error box where "Checking for authentication…" had been:

Setup is not complete
Create the first user with the setup token from the output of coder server. You can sign in after that.

The browser was not signed in and no user exists. Before this PR the first OAuth sign-in on a server with no users created the Owner. The 403 status of the refused request was not captured in the browser. TestUserOAuth2Github/SetupTokenBlocksFirstUser checks it (scenario 22).

8. The setup page asks for the token and hides the GitHub button

Browser: open the tunnel URL. It lands on /setup. Read from the page:

inputs, in order:   setup_token (type password, empty)   email (type text, empty)   password (type password, empty)
buttons with text:  Continue

Setup token
Printed by coder server when it starts.
Email
To switch this account to GitHub sign-in later, use your GitHub account's primary email. You switch it under Account > Security.
Password

"Setup token" is the first field and hides what is typed. The only button is Continue. There is no GitHub button and no "or" divider, so the page does not lead into the refusal of scenario 7. The word GitHub appears once, in the Email hint.

9. A wrong token on the setup page

Browser: type not-the-token in Setup token, the primary email of the GitHub account in Email, the test password in Password, and select Continue.

# workspace
hasuser "$U"
alert:               A setup token is required to create the first user. Find it in the output of coder server.
setup_token field:   red border, aria-invalid="true", text under it "Missing or incorrect setup token."
email field:         still filled
password field:      still 24 characters
page:                still /setup
first user check -> 404

The form shows the server's message, marks the token field, and keeps the other fields. The alert is at the bottom of the form by the Continue button and the marked field is at the top, so on a short window they are a screen apart.

10. The right token on the setup page creates the Owner
# laptop: put the token on the clipboard without printing it
coder ssh <workspace> -- 'source ~/core784b/helpers.sh; printf %s "$(tok t1)"' </dev/null | pbcopy
# browser: clear the Setup token field, paste, select Continue
# workspace
hasuser "$U"
first user check -> 200
page after Continue:   /templates/new/builder, signed in, no alert
audit log:             2026-11-17 20:42:24.771  first entry, the user was created
GET /api/v2/users:     count 1, roles ["owner"], login_type "password", status "active"
Users page:            1 row, role Owner, "Showing 1 to 1 of 1 user"

The email, the password and the browser session were the same as in scenario 9. Only the token changed. The server had been public with no users for 32 minutes, and every first-user attempt in that time was refused.

11. The first account switches to GitHub sign-in and signs in with it

Browser, by selecting only: the user menu, then Account, then Security. No address was typed.

user menu           has the entry "Account"
select "Account"    lands on /settings/account, the sidebar has "Security"
select "Security"   lands on /settings/security
headings there      Security, Password, Single Sign On
Single Sign On      one button, "GitHub", enabled

Then: select GitHub, confirm with the password, complete the device flow on GitHub.

2026-11-17 20:47:14.409  audit_log  ResourceType=convert_login  Action=create  StatusCode=201
2026-11-17 20:47:41.934  audit_log  ResourceType=user  Action=write  StatusCode=200  … login_type":{"Old":"password","New":"github","Secret":false} …
page:   /login, "Login type has been changed to Github. Log in again using the new method."

Then: select GitHub on the sign-in page and complete the device flow.

2026-11-17 20:53:53.411  audit_log  ResourceType=api_key  Action=login  StatusCode=200
page:                  /workspaces, signed in
GET /api/v2/users/me:  login_type "github", roles ["owner"], status "active", id 07aea856-…
GET /api/v2/users:     count 1, login types ["github"]

The user id is the one the audit log gave the first user in scenario 10, and the deployment still has one user. So GitHub signed in to the existing account and created no second one, and the account is still Owner. A sign-in with the email and the old password was then refused with "Incorrect email or password."

The server also logged one warning during the switch. See fact 8.

2026-11-17 20:47:41.930 [warn]  coderd: failed to delete old API key in convert to oidc  …
    error= no authorization actor in context:
12. After setup the token does nothing
# workspace, t1 has one user
T=$(tok t1)
post_first "$U" "$T" second@example.com
post_first "$U" - second@example.com
post_first "$U" "not-the-token-not-the-token-0000" second@example.com | tail -1
methods "$U"
{"message":"The initial user has already been created."}

-> 409
{"message":"The initial user has already been created."}

-> 409
-> 409
{"setup_token_required":true,"github":true,"password":true}

The right token, no token and a wrong token all get the same 409. A token that leaks after setup cannot create a second Owner, and the answer does not say whether it was right. The last line is fact 7.

13. A restart with a user prints no token and requires none
# workspace
U1=$(turl t1); srv_stop t1; srv_start t1; srv_wait t1
tokinfo t1
grep -ci 'setup token' ~/core784b/logs/t1.2.log
[ "$(turl t1)" = "$U1" ] && echo "same URL" || echo "URL changed"
curl -s "$U1/api/v2/users/authmethods"; echo
hasuser "$U1"
srv_stop t1
t1 stopped at 21:45:18
started t1 pid 180787 log /home/coder/core784b/logs/t1.2.log at 21:45:18
t1 ready at 21:45:20
t1: no setup token line
0
same URL
{"password":{"enabled":true},"github":{"enabled":true,"default_provider_configured":true},"oidc":{"enabled":false,"signInText":"","iconUrl":""}}
first user check -> 200
t1 stopped at 21:45:22

The second start prints no token, and the setup_token_required key is gone from the answer, which is then the same JSON as before this PR.

14. A restart before setup gives a new token
# workspace, a new config directory
srv_start t2; srv_wait t2; tokinfo t2; OLD=$(tok t2)
srv_stop t2
srv_start t2; srv_wait t2; tokinfo t2; NEW=$(tok t2)
[ -n "$OLD" ] && [ -n "$NEW" ] && [ "$OLD" != "$NEW" ] && echo "tokens differ" || echo "TOKENS DO NOT DIFFER"
U=$(turl t2)
post_first "$U" "$OLD" | tail -1
hasuser "$U"
grep -rlF "$OLD" ~/core784b/cfg/t2 | wc -l; grep -rlF "$NEW" ~/core784b/cfg/t2 | wc -l
find ~/core784b/cfg/t2 -type f | wc -l
started t2 pid 181672 log /home/coder/core784b/logs/t2.1.log at 21:47:22
t2 ready at 21:47:34
t2: len=32 alnum=yes fp=d2d46f43999e lines_with_token=1 token_lines=1
t2 stopped at 21:47:36
started t2 pid 181839 log /home/coder/core784b/logs/t2.2.log at 21:47:36
t2 ready at 21:47:38
t2: len=32 alnum=yes fp=1fb77ed66d3c lines_with_token=1 token_lines=1
tokens differ
-> 403
first user check -> 404
0
0
2936

Two starts of one config directory give two tokens, and the first is refused by the second start. Neither is in any of the 2936 files of the config directory, so the token is not stored. t2 had the same public URL as t1. See fact 4.

15. coder login asks for the token first

coder login needs a terminal for its prompt. A short script ran it in a pseudo-terminal, waited for the prompt, sent an empty line, waited for the prompt again, and sent not-the-token-not-the-token.

# workspace, t2 has no users
"$BIN" --global-config ~/core784b/client login "$U" --no-open \
  --first-user-email cli-admin@example.com --first-user-username cli-admin \
  --first-user-full-name "CLI Admin" --first-user-password "$(cat ~/core784b/pw)" \
  --first-user-trial=false
hasuser "$U"
Attempting to authenticate with argument URL: 'https://<id>.pit-1.try.coder.app'
  Your Coder deployment hasn't been set up!
> Setup token: 
The setup token is printed by coder server when it starts.
> Setup token: ***************************
Encountered an error running "coder login", see "coder login --help" for more information
error: Trace=[create initial user: ]
A setup token is required to create the first user. Find it in the output of coder server.
1 validation error(s) found
	 setup_token : Missing or incorrect setup token.
first user check -> 404

The token is the first and only question, since the email and password come by flag. An empty answer is not sent. A wrong answer ends the command with the server's message. The same command run by hand in a terminal ended with the same five error lines and exit 1. See fact 5.

16. coder login with --first-user-setup-token
# workspace, no terminal attached
T=$(tok t2)
"$BIN" --global-config ~/core784b/client login "$U" --no-open \
  --first-user-email cli-admin@example.com --first-user-username cli-admin \
  --first-user-full-name "CLI Admin" --first-user-password "$(cat ~/core784b/pw)" \
  --first-user-trial=false --first-user-setup-token "$T" </dev/null 2>&1 |
  sed "s/$T/<token>/g"; echo "exit ${PIPESTATUS[0]}"
hasuser "$U"
env -u CODER_URL -u CODER_SESSION_TOKEN "$BIN" --global-config ~/core784b/client whoami
env -u CODER_URL -u CODER_SESSION_TOKEN "$BIN" --global-config ~/core784b/client users show cli-admin | grep Roles
"$BIN" login --help | grep -A2 -- '--first-user-setup-token'
Attempting to authenticate with argument URL: 'https://<id>.pit-1.try.coder.app'
  Your Coder deployment hasn't been set up!
Welcome to Coder, cli-admin! You're authenticated.Get started by creating a template: coder templates init
exit 0
first user check -> 200
Coder is running at https://<id>.pit-1.try.coder.app, You're authenticated as cli-admin !
Roles:          Owner
      --first-user-setup-token string, $CODER_FIRST_USER_SETUP_TOKEN
          Specifies the setup token to use if creating the first user for a
          deployment that requires one. The server prints it at startup.

No prompt, and the output does not contain the token. The two whoami lines were run after a restart of t2, with the workspace's own CODER_URL and CODER_SESSION_TOKEN removed. See fact 12.

17. A supplied token that is too short stops a tunnel server
# workspace, a new config directory, 23 characters
CODER_SETUP_TOKEN=abcdefghijklmnopqrstuvw srv_start t3; srv_wait t3
tail -2 ~/core784b/logs/t3.1.log
grep -cF abcdefghijklmnopqrstuvw ~/core784b/logs/t3.1.log
started t3 pid 193162 log /home/coder/core784b/logs/t3.1.log at 22:17:05
t3 exited at 22:17:17 before the logs line
Encountered an error running "coder server", see "coder server --help" for more information
error: --setup-token must be at least 24 characters
0

The server stops before it serves the API. The error names the option and not the value.

18. A supplied token is used and is not shown
# workspace, 32 random characters in a file of mode 600
S=$(cat ~/core784b/supplied)
CODER_SETUP_TOKEN=$S srv_start t3; srv_wait t3
masked t3 | tail -3
tokinfo t3
U=$(turl t3); methods "$U"
post_first "$U" - scripted@example.com | tail -1
post_first "$U" "$S" scripted@example.com | tail -1
# sign in as the new Owner and read the deployment settings
curl -s -H "Coder-Session-Token: $SESSION" "$U/api/v2/deployment/config" >/tmp/cfg.json
grep -cF "$S" /tmp/cfg.json
jq -c '.options[] | select(.flag == "setup-token") | {flag, env, yaml, annotations, value, value_source}' /tmp/cfg.json
grep -cF "$S" ~/core784b/logs/t3.2.log
A setup token is needed to create the first user. It was set with --setup-token or CODER_SETUP_TOKEN.

==> Logs will stream in below (press ctrl+c to gracefully exit):
t3: no setup token line
{"setup_token_required":true,"github":true,"password":true}
-> 403
-> 201
0
{"flag":"setup-token","env":"CODER_SETUP_TOKEN","yaml":null,"annotations":{"secret":"true"},"value":null,"value_source":"env"}
0

The server says a token was supplied and does not print it. The supplied value creates the first user and a request without it is refused. The value is in 0 lines of the log and is hidden in the 163 KB deployment settings response, the same way the database URL is. The option has no YAML key.

19. With an access URL nothing changes
# workspace, loopback access URL and a supplied token of 32 characters
U=http://127.0.0.1:3400
CODER_SETUP_TOKEN=$(cat ~/core784b/supplied) srv_start t4 --access-url "$U"; srv_wait t4
grep -c 'Opening tunnel' ~/core784b/logs/t4.log
grep 'setup-token is ignored' ~/core784b/logs/t4.log
tokinfo t4
methods "$U"
post_first "$U" - plain@example.com | tail -1
hasuser "$U"; srv_stop t4

# the same with a supplied token of 23 characters
CODER_SETUP_TOKEN=abcdefghijklmnopqrstuvw srv_start t5 --access-url "$U"; srv_wait t5
grep -c 'setup-token must be at least 24 characters' ~/core784b/logs/t5.log
grep -c 'setup-token is ignored because an access URL is set' ~/core784b/logs/t5.log
methods "$U"; srv_stop t5
t4 ready at 22:18:05
0
WARN: --setup-token is ignored because an access URL is set. A setup token is required only on a try.coder.app tunnel. To create the first user before the server can be reached, run coder server create-admin-user.
t4: no setup token line
{"setup_token_required":null,"github":true,"password":true}
-> 201
first user check -> 200
t5 ready at 22:18:32
0
1
{"setup_token_required":null,"github":true,"password":true}

No tunnel, no token printed, none required, and a request with no token creates the first user, as before this PR. A supplied token is ignored with a warning that says what to do, and its length is not checked when it is ignored. The same 23 characters stopped the tunnel server in scenario 17.

20. ./scripts/develop.sh on a tunnel
# workspace, worktree at 1b79d798f1. develop creates the admin itself.
./scripts/develop.sh --access-url "" --port 3400 --web-port 8480 --starter-template= >"$L" 2>&1 &
# wait for the banner
grep -c 'Coder is now running in development mode.' "$L"
grep 'It was set with\|Logs will stream' "$L"
grep -c 'Setup token:' "$L"
methods http://127.0.0.1:3400; hasuser http://127.0.0.1:3400
for p in $(pgrep -f 'coder.*server.*3400'); do tr '\0' '\n' </proc/$p/environ | grep -c '^CODER_SETUP_TOKEN=.\{32\}$'; done
pgrep -af 'coder|develop' | grep -c 'setup-token'

# the same with --skip-setup, on a new database
./scripts/develop.sh --access-url "" --port 3400 --web-port 8480 --starter-template= --skip-setup >"$L2" 2>&1 &
grep 'Setup token:\|setup token is needed\|Logs will stream' "$L2" | sed -E 's/(Setup token: )[A-Za-z0-9]+/\1<token>/'
grep -c 'It was set with' "$L2"
methods http://127.0.0.1:3400; hasuser http://127.0.0.1:3400
post_first http://127.0.0.1:3400 - | tail -1
post_first "$TUNNEL_URL" "$T" dev-hand@example.com | tail -1
1
2026-11-17 22:26:14.977 [info]  api: A setup token is needed to create the first user. It was set with --setup-token or CODER_SETUP_TOKEN
2026-11-17 22:26:14.977 [info]  api: ==> Logs will stream in below (press ctrl+c to gracefully exit):
0
{"setup_token_required":true,"github":true,"password":true}
first user check -> 200
1
0
2026-11-17 22:38:43.806 [info]  api: Setup token: <token>
2026-11-17 22:38:43.806 [info]  api: The setup token is needed to create the first user. Enter it on the setup page, or when coder login asks for it.
2026-11-17 22:38:43.806 [info]  api: ==> Logs will stream in below (press ctrl+c to gracefully exit):
0
{"setup_token_required":true,"github":true,"password":true}
first user check -> 404
-> 403
-> 201

With setup, develop reached its banner in 55 seconds with no manual step. The server required a token and a user existed five seconds after the server was ready, and only develop held the token. The token was in the server's environment and on no command line. With --skip-setup, develop supplies no token, the server prints its own, and that token finishes setup by hand.

21. Docs and reference
# workspace, worktree
grep -n -i 'setup token' docs/install/index.md docs/get-started/index.md \
  docs/install/server/rpm.md docs/install/server/cloud/azure-vm.md \
  docs/install/server/cloud/compute-engine.md | cut -d: -f1 | sort | uniq -c
grep -c 'Continue with GitHub' docs/get-started/index.md
grep -c 'Account\*\* > \*\*Security' docs/install/index.md docs/get-started/index.md
grep -c -- '--setup-token' docs/reference/cli/server/index.md
grep -c -- '--first-user-setup-token' docs/reference/cli/login/index.md
grep -c 'setup_token' docs/reference/api/schemas.md
grep -rl -i 'try.coder.app' docs --include='*.md' | sort
      3 docs/get-started/index.md
      1 docs/install/index.md
      1 docs/install/server/cloud/azure-vm.md
      2 docs/install/server/cloud/compute-engine.md
      1 docs/install/server/rpm.md
0
docs/install/index.md:1
docs/get-started/index.md:1
1
1
7
docs/admin/monitoring/notifications/index.md
docs/admin/setup/configuration-reference.md
docs/get-started/index.md
docs/install/index.md
docs/install/server/cloud/azure-vm.md
docs/reference/cli/server/index.md

All five install pages say where the token is. The words agree with the run: the line starts with Setup token: (scenario 2), coder login asks for it (scenario 15), and the switch is under Account, then Security (scenario 11). Of the six pages that name the tunnel, three are among the five, two are generated reference, and one has a tunnel address only inside an example message. Step 3 of the quickstart lists Setup token, Email, Password, in the order of the form.

22. Unit tests on Linux
# workspace, worktree
go test ./coderd/ -run 'TestFirstUser|TestUserOAuth2Github|TestUserOIDC' -count=1
go test ./cli/ -run 'TestResolveSetupToken|TestLogin|TestServer/.*Help|TestCommandHelp' -count=1
go test ./codersdk/ -run 'TestDeploymentValues' -count=1
go test ./scripts/develop/ -count=1
( cd site && pnpm vitest run --project=unit src/pages/SetupPage )
ok  	github.com/coder/coder/v2/coderd	6.771s
ok  	github.com/coder/coder/v2/cli	1.924s
ok  	github.com/coder/coder/v2/codersdk	0.060s
ok  	github.com/coder/coder/v2/scripts/develop	1.009s
 ✓  unit  src/pages/SetupPage/SetupPage.test.tsx (4 tests) 2034ms
 Test Files  1 passed (1)
      Tests  4 passed (4)

A second run with -v listed the tests by name, since a pattern that matches nothing also prints ok. All of these passed: TestFirstUser/SetupToken, TestUserOAuth2Github/SetupTokenBlocksFirstUser, TestUserOIDC/SetupTokenBlocksFirstUser, the nine subtests of TestResolveSetupToken, TestDevConfigServerCmdSetupToken and TestSetupFirstUser/SendsSetupToken. The three coderd groups had 83 results, none failed and none was skipped. The OIDC test covers the path this run had no provider for.

23. Cleanup
# workspace
pgrep -af 'coder_linux_amd64|develop' | grep -c core784b
git -C ~/coder worktree remove --force ~/core784b/src && git -C ~/coder worktree prune
rm -rf ~/core784b
rm -f ~/.config/coderv2/devtunnel      # created by the first server of this run
# laptop
curl -s -o /dev/null -m 8 -w '%{http_code}\n' "$U/api/v2/buildinfo"
0
502
  • Every server was stopped before its scenario ended. The last one stopped at 22:39 UTC.
  • The worktree, the five config directories with their databases, the develop database and the tunnel key are gone. The tunnel address answers 502, so nothing is behind it.
  • Four server logs hold a setup token and one holds two dev passwords. Every one of those servers and databases is deleted, so the values open nothing.
  • The Coder GitHub app is still authorized on the GitHub account used for scenarios 7 and 11.

@linear-code

linear-code Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

CORE-784

CORE-891

CORE-894

@BobbyHo

BobbyHo commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

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

@coder-agents-review

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

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-11-17 17:53 UTC by @BobbyHo
Spend: $25.43 / $100.00

Review history
  • R1 (2026-11-17): 15 reviewers, 1 P1, 4 P2, REQUEST_CHANGES. Review
  • R2 (2026-11-17): 12 reviewers, 1 P1, 4 P2, APPROVE. Review

deep-review v0.13.0 | Round 2 | 070107c..25e107b

Last posted: Round 2, 5 findings (1 P1, 4 P2), APPROVE. Review

Finding inventory

Finding inventory: PR #32324

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P1 Author fixed (5cc3a3f) cli/setuptoken.go:44 // nolint:gocritic fails nolintlint in lint/go/new-code R1 Netero Yes
CRF-2 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:14 setup_token_required stays true after first user exists R1 Netero No
CRF-3 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.stories.tsx:49 SetupTokenRefused play function asserts nothing R1 Netero No
CRF-4 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.stories.tsx:26 SetupTokenRequired has no play function for hidden GitHub button and hint R1 Netero No
CRF-5 P2 Author fixed (f5a0da2) site/src/pages/SetupPage/SetupPageView.tsx:173 Email hint and docs/install/index.md:32 promise GitHub sign-in that is refused with "Incorrect login type" R1 Leorio P2, Kurapika P3, Nami P3, Luffy P3, Melody P3, Pen Botter P3, Mafuuu P3, Bisky P3 Yes
CRF-6 P2 Author contested; panel closed R2 (2/2 accept) cli/setuptoken.go:35 Supplied setup token is ignored whenever an access URL is set R1 Pariston P2, Pen Botter P3 Yes
CRF-7 P2 Author fixed (f5a0da2) docs/get-started/index.md:206 Quickstart Step 3 still offers "Continue with GitHub" for the first user R1 Pen Botter Yes
CRF-8 P2 Author fixed (f5a0da2) docs/install/server/cloud/compute-engine.md:42 GCP Marketplace guide does not say where to find the setup token R1 Pen Botter Yes
CRF-9 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/userauth.go:1784 With --disable-password-auth on a tunnel, the only possible first user cannot sign in R1 Ryosuke No
CRF-10 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/login.go:255 Non-interactive coder login without the token flag hits EOF or waits on stdin R1 Mafuuu No
CRF-11 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.tsx:79 Failed authMethods query hides the token field with no recovery but reload R1 Nami No
CRF-12 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) docs/get-started/index.md:194 Token is documented only on the fallback tunnel-URL path R1 Luffy P3, Pen Botter P4 No
CRF-13 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/server.go:1052 Browser opened by coder server cannot receive the token; local operator must copy it R1 Luffy No
CRF-14 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:65 Nothing says only the latest printed token is valid after restarts R1 Pen Botter No
CRF-15 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/server.go:1052 No test or manual run covers the tunnel != nil activation of the token R1 Bisky No
CRF-16 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:15 "about 142 bits" comment claims a strength the length-only check does not enforce R1 Gon P2, Kurapika P4 No
CRF-17 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.tsx:107 Token is trimmed only by the web client, not by coder login or the server R1 Gon P3, Melody P4, Zoro P4 No
CRF-18 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:31 Length check stops the server for a token that is ignored with an access URL R1 Mafuuu No
CRF-19 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:30 Refusal and hints say the token is printed, but a supplied token is not printed R1 Mafuuu No
CRF-20 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:53 Comment first sentence restates the code R1 Gon P2 No
CRF-21 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:12 setupTokenRequired doc comment restates the body R1 Gon P2 No
CRF-22 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/userauth.go:1782 Comment names a tunnel condition the code does not check R1 Gon P2 No
CRF-23 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.tsx:104 Comment and wrapper justify omitting an empty token, which has no server effect R1 Gon P2, Zoro P4 No
CRF-24 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) scripts/develop/main.go:856 serverCmd doc comment restates the name R1 Gon P2 No
CRF-25 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/login.go:253 Comment says token is asked first; it is asked after username and name R1 Mafuuu No
CRF-26 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:61 Generated token length 32 is an unnamed literal repeated in develop and the test R1 Gon No
CRF-27 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken.go:61 cryptorand.String(32) and its error branch can be crypto/rand.Text() R1 Ging-Go No
CRF-28 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) codersdk/deployment.go:4022 Option description hardcodes 24 separately from setupTokenMinLength R1 Gon No
CRF-29 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/login.go:266 Empty-input validation error does not say input is missing R1 Gon No
CRF-30 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:39 setupTokenRefused and errSetupNotComplete use two naming schemes R1 Gon No
CRF-31 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:28 Zero-argument single-caller response helpers could be inline literals R1 Zoro No
CRF-32 P4 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) cli/setuptoken_internal_test.go:133 ptrInt64 duplicates new(expr) and ptr.Ref R1 Ging-Go P4, Gon Nit No
CRF-33 Nit Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPage.test.tsx:139 New page behavior tested in RTL file instead of a story R1 Bisky No
CRF-34 OOS Out of scope (body) coderd/users.go:178 Access-URL deployments with no users still allow anyone to create the Owner R1 Kurapika No
CRF-35 Note Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) coderd/setuptoken.go:20 setupTokenMatches repeats secretsEqual in chatwebhook R1 Zoro No
CRF-36 Note Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnmgEFA) site/src/pages/SetupPage/SetupPageView.tsx:133 GitHub first-user sign-up could carry the token in a same-origin cookie R1 Luffy No
CRF-37 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnqCfWQ) docs/get-started/index.md:212 Step 3 screenshot still shows the form without the setup token field R2 Pen Botter P3, Leorio P3 No
CRF-38 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnqCfWQ) cli/setuptoken.go:39 Ignored-token warning does not say to stop the server before create-admin-user and names only the flag R2 Leorio No
CRF-39 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnqCfWQ) docs/install/server/cloud/compute-engine.md:49 journalctl lines do not start with "Setup token:" and a boot can print several tokens R2 Leorio No
CRF-40 P3 Dropped by orchestrator (author requested P0-P2 only, IC_kwDOGkVX1s8AAAABnqCfWQ) docs/install/server/cloud/azure-vm.md:87 Same journalctl "line that starts with" and multiple-token problem R2 Leorio No
CRF-41 OOS Out of scope (body) coderd/database/migrations/000643_chat_project_templates.up.sql:1 Base branch has two 000643 migrations, so every database-backed test fails R2 Netero, Ryosuke, Kurapika, Kite No

Contested and acknowledged

CRF-6 (P2, cli/setuptoken.go:35) - Supplied setup token ignored when an access URL is set

  • Finding: resolveSetupToken ignores a supplied --setup-token with a warning whenever an access URL is set, so an operator cannot protect a publicly reachable non-tunnel deployment (Helm binds 0.0.0.0:8080). Proposed: keep generation tunnel-only, but return a supplied token whenever the user count is 0, regardless of onTunnel.
  • Author defense (PRRC_kwDOGkVX1s8AAAABEmPEvQ): Enforcing a supplied token with an access URL also turns on the oauthLogin first-user refusal, so the first user must be a password account; with --disable-password-auth that Owner cannot sign in, because the option applies to owners too. Access-URL deployments with an identity provider are the most likely to set the token, so this needs its own design with the wider access-URL case. Tracked in CORE-891. In 9f4cd1d the length check now runs only when the token is used, and the ignore warning names coder server create-admin-user.
  • Panel closure (R2, 2/2): Pariston and Pen Botter, both the agents that raised it in R1, accepted. Each verified that --disable-password-auth refuses password sign-in for owners too (coderd/userauth.go:598-604) and that enforcing a supplied token turns on the oauthLogin refusal (coderd/userauth.go:1784), so the proposed fix would lock out the Owner on identity-provider deployments with password auth disabled. The warning at cli/setuptoken.go:38-40 names coder server create-admin-user, and 9f4cd1d moves the length check to the path that uses the token. The access-URL case is tracked in CORE-891. This closure holds while oauthLogin refuses OAuth first users whenever a token is required.

Round log

Round 1

Full panel (round 1). Netero P1 at most, so the panel ran. Law not run (effective additions 745). Panel: ging-go, ging-ts, ging-react, kurapika, nami, ryosuke, luffy, melody, pen-botter (triggered specialists), pariston, mafuuu (core), bisky (tests), gon, leorio (once-per-PR floor), zoro (wildcard). 15 reviewers, above the 9-12 target because 9 domain specialists were triggered (Go, TS, React, auth/token, frontend, Go API, new config surface, wire-format fields, docs) plus required Bisky and the Gon/Leorio floor.

The author asked in IC_kwDOGkVX1s8AAAABnmgEFA to limit the review to P0, P1, and P2. Only P0-P2 findings are posted; P3 and below are recorded here as dropped for that reason, and the review body states the count. Keep-argument against withholding: the findings are valid and there is no follow-up; the author's explicit request decides.

Severity decisions:

  • CRF-5: Leorio P2 vs seven reviewers at P3. Raised to P2: Leorio, Luffy, Pen Botter, and Bisky reproduced the refusal with a scratch test, and the hint is shown on most default tunnel installs.
  • CRF-6: Pariston P2, Pen Botter P3. P2 kept (higher wins, Pariston cites Helm binding and the passing test that encodes the ignore).
  • CRF-16: Gon P2, Kurapika P4. Keep-argument for P2: a security comment states a strength the code does not enforce and could guide a future change to the minimum. Set to P3: no runtime consequence; the generated token is unaffected.
  • CRF-20 to CRF-24: Gon P2. Keep-argument: inaccurate comments (CRF-22 names a tunnel condition not checked) mislead readers. Set to Nit: the code works and these are comment-convention issues with no behavior change.

CI: lint, check-build, engine fail. CRF-1 reproduces a lint failure. gh returns HTTP 401 here, so the other two logs were not read.

Reviewed against 81a51b1..2e57b46.

Round 2

Fix round, not a restructure: commits since R1 (5cc3a3f rebase, 50a720c slim build tag, 9f4cd1d length check, f5a0da2 docs and hint) patch prior findings and add no files to the tree; compute-engine.md is an existing file newly touched. Base moved to 070107c (stacked branch merged main). Churn guard PROCEED: CRF-1, CRF-5, CRF-7, CRF-8 addressed; CRF-6 contested with CORE-891. Netero: no findings. Panel: pariston, pen-botter (dispute check-in, previous agents reused via message_agent), ging-go, ryosuke, kurapika (cli/setuptoken.go), nami, ging-ts, ging-react (SetupPageView.tsx), gon (nolint comment line), leorio (warning text, docs), bisky (test changes), kite (wildcard).

CRF-6 closed 2/2. Fixes for CRF-1, CRF-5, CRF-7, CRF-8 verified by Netero, Nami, Bisky, Kite, Pen Botter, Leorio. New: 4 P3 (CRF-37 to CRF-40), recorded and not posted per the author's repeated P0-P2 request (IC_kwDOGkVX1s8AAAABnqCfWQ). CRF-41 out of scope.

CI: engine is the job in .github/workflows/docs-pr-preview-deploy.yaml (verified by grep); Kurapika and Kite attributed it to the duplicate migration, which Netero's workflow evidence contradicts. Its log was not read (gh HTTP 401). The duplicate 000643 migration is verified present in the tree.

Reviewed against 070107c..25e107b.

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 requires a setup token to create the first user when coder server runs on a try.coder.app tunnel. Findings: 1 P1, 4 P2.

As requested, only P0 to P2 findings are posted. 30 lower-severity findings and notes were recorded and are available on request. check-build and engine also fail; their logs could not be read from this environment, so their cause is unknown.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/users.go:178: a deployment with an access URL set and no users still lets anyone who reaches it create the Owner through POST /api/v2/users/first, so the first-user takeover remains open outside the tunnel case.

docs/get-started/index.md:206

P2 [CRF-7] Step 3 of the quickstart still says the first user can choose Continue with GitHub, but on the tunnel this quickstart uses, the setup page hides that button and oauthLogin refuses an OAuth first user. (Pen Botter)

Step 3 also does not mention the "Setup token" field, and the welcome-create-admin-user.png screenshot shows the old form. Replace the GitHub sentence with a step to enter the token from the Setup token: line, then create the account with an email and password.

🤖

docs/install/server/cloud/compute-engine.md:42

P2 [CRF-8] The GCP Marketplace guide ends with "Use the UI to create your first user", but on its tunnel URL the UI now asks for a setup token that the guide never says how to find. (Pen Botter)

The guide says the instance redirects to a public tunnel URL, so resolveSetupToken requires a token, and a user who launched a Marketplace image never saw the coder server output. Add the step this PR adds to azure-vm.md: SSH to the VM, run journalctl -u coder.service -b, and copy the Setup token: line. Whether the Marketplace image starts without an access URL was not confirmed by launching it.

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread cli/setuptoken.go Resolved
Comment thread cli/setuptoken.go Resolved
A server published through a try.coder.app tunnel let the first
visitor become Owner. The server now prints a setup token at startup
when it opened a tunnel and no user exists. The first-user endpoint
refuses a request without it, and an OAuth sign-in cannot create the
first user until setup is complete.
The slim binary must not import coderd/rbac, and the setup token code
reaches it through dbauthz. It is only used by the server command,
which is already left out of slim builds.

Also write the nolint directive without a leading space.
@BobbyHo
BobbyHo force-pushed the bobby/core-784-setup-token branch from 5a349b3 to 50a720c Compare November 17, 2026 16:14
A short --setup-token stopped the server even when an access URL was
set and the token was ignored. The warning for an ignored token now
names coder server create-admin-user.
The setup page hint and the install page said a matching email is
enough to sign in with GitHub later. The account must also be switched
under Account > Security. The quickstart and the GCP guide now say
where to find the setup token.
@BobbyHo

BobbyHo commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to the two findings in the review body, both fixed in f5a0da2.

CRF-7, docs/get-started/index.md

  • Step 3 now starts with a "Setup token" bullet that says to copy it from the Setup token: line of the coder server output.
  • The "Continue with GitHub" sentence is removed. In its place: create the account with your GitHub primary email, then switch it to GitHub sign-in under Account > Security.
  • The earlier paragraph said the page asks for the token "when you use this URL" (the tunnel URL). The requirement is set for the whole server, so it now says the page asks for it whichever URL you use.
  • Not done: welcome-create-admin-user.png still shows the form without the token field. Replacing it needs a run on a real tunnel.

CRF-8, docs/install/server/cloud/compute-engine.md

  • Before "That's all!", the guide now says the setup page asks for a setup token, and to connect over SSH, run journalctl -u coder.service -b, and copy the Setup token: line.
  • Not confirmed by launching the Marketplace image: that it runs Coder as coder.service. The name comes from the systemd unit the Linux packages install.

@BobbyHo

BobbyHo commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

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

@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.

Re-review of the fixes for the five findings from the previous review. No new P0 to P2 findings.

The nolint directive, the GitHub sign-in hint and docs/install/index.md, quickstart Step 3, and the GCP Marketplace guide are fixed. The finding about a supplied token being ignored with an access URL is closed: the --disable-password-auth lockout in the reply holds in the code (coderd/userauth.go:598-604), the warning now names coder server create-admin-user, and CORE-891 tracks the access-URL case. As requested, 4 P3 findings from this round are recorded and not posted. The failing engine job belongs to docs-pr-preview-deploy.yaml; its log could not be read here.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/database/migrations/000643_chat_project_templates.up.sql:1: the base branch has two migrations numbered 000643, so every database-backed test fails with duplicate migration file: 000643_skill_display_name.down.sql until the base branch merges main, which renumbers it to 000644. With that rename applied locally, the setup-token tests in cli and coderd pass.

🤖 This review was automatically generated with Coder Agents.

@BobbyHo
BobbyHo marked this pull request as ready for review November 17, 2026 23:04
@BobbyHo
BobbyHo requested review from a team, Emyrk and geokat November 17, 2026 23:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant