Repository navigation
chore: sync upstream 88d3494b9a - #406
Conversation
…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
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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 👍 / 👎.
| setup_token: setupTokenRequired | ||
| ? Yup.string().trim().required("Please enter the setup token.") |
There was a problem hiding this comment.
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 👍 / 👎.
| if userCount == 0 && api.setupTokenRequired() { | ||
| return errSetupNotComplete() |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 👍 / 👎.
Merges upstream
coder/codermain up to 88d3494.New upstream migrations and their routes:
This PR merges itself when fork-ci passes.
Opened by the fork-sync workflow.