Skip to content

chore: sync upstream 88d3494b9a - #406

Merged
ibetitsmike merged 2 commits into
mainfrom
sync/2026-11-21-88d3494b9a
Nov 21, 2026
Merged

ibetitsmike merged 2 commits into
mainfrom
sync/2026-11-21-88d3494b9a

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Merges upstream coder/coder main up to 88d3494.

New upstream migrations and their routes:

This PR merges itself when fork-ci passes.

Opened by the fork-sync workflow.

BobbyHo and others added 2 commits November 19, 2026 20:22
…er#32324)

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
@ibetitsmike ibetitsmike added the sync Upstream sync label Nov 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T05:08:59.250082Z 7e4081e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e4081e0e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

isLoading,
authMethods,
}) => {
const setupTokenRequired = authMethods?.setup_token_required ?? false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop setup when auth-method discovery fails

If the auth-methods request exhausts its retries, authMethods is undefined and this fallback treats the setup token as optional. A token-protected deployment then hides the token field and submits a request the server must reject, leaving the user unable to complete setup. Handle authMethodsQuery.error in SetupPage instead of rendering the form with missing data.

AGENTS.md reference: site/AGENTS.md:L11-L11

Useful? React with 👍 / 👎.


export const SetupTokenRequired: Story = {
args: {
authMethods: {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse a shared setup-token auth-method fixture

This story defines a complete AuthMethods entity inline while the corresponding test independently derives the same setup-token variant from MockAuthMethodsPasswordOnly. These copies can drift as the API shape changes; define a shared MockAuthMethodsSetupTokenRequired fixture and use it in both places.

AGENTS.md reference: site/AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Comment on lines +46 to +47
setup_token: setupTokenRequired
? Yup.string().trim().required("Please enter the setup token.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Capture the missing setup-token validation state

The new required-token validation has no visual coverage: SetupTokenRequired never submits the form, while SetupTokenRefused enters a nonempty token before submission. Add a story whose play function fills the other required fields and submits with the token blank so Pixel captures this new error state.

AGENTS.md reference: site/AGENTS.md:L7-L7

Useful? React with 👍 / 👎.

Comment thread coderd/userauth.go
Comment on lines +1784 to +1785
if userCount == 0 && api.setupTokenRequired() {
return errSetupNotComplete()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve setup when password authentication is disabled

On a tunneled deployment with CODER_DISABLE_PASSWORD_AUTH=true, this rejects the first GitHub or OIDC login, leaving the token-bearing first-user endpoint as the only setup path. That endpoint creates a password-login owner, but loginWithPassword unconditionally rejects every password login when the setting is enabled, so the UI and CLI create the owner and then fail to authenticate, potentially leaving the deployment without any usable owner session. Support carrying the setup authorization through external authentication or reject this configuration before creating an unusable account.

Useful? React with 👍 / 👎.

// An empty token is left out, so that the request to a server
// that requires no token stays as it was.
onSubmit: ({ setup_token, ...firstUser }) => {
const token = setup_token?.trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize configured and submitted setup tokens consistently

When an operator supplies CODER_SETUP_TOKEN or --setup-token with leading or trailing whitespace, the server stores and compares that value verbatim, but the web form always trims it before submission. Such an accepted configuration can therefore never be completed through the setup page. Normalize the configured token on the server or preserve the submitted value so both sides compare the same token.

Useful? React with 👍 / 👎.

@ibetitsmike
ibetitsmike merged commit 415b6b5 into main Nov 21, 2026
11 checks passed
@ibetitsmike
ibetitsmike deleted the sync/2026-11-21-88d3494b9a branch November 21, 2026 05:12
ibetitsmike added a commit that referenced this pull request Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync Upstream sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants