Repository navigation
fix(auth): turn signup approval on by default - #2919
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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. |
|
@coderabbitai review |
Action not completed
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b20c52541
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Addresses Codex review on #2919. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signup approval was off unless REQUIRE_APPROVAL was exactly "true", so a self-hosted installation reachable from the internet handed an active account to anyone who could sign in. It is now on unless the deployment sets REQUIRE_APPROVAL=false; any other value, including unset or a typo, keeps it on. The Admin -> Users runtime switch still overrides it, and the first real account is still promoted to an active superadmin. The canonical production and staging environments already set REQUIRE_APPROVAL=true, so they do not change. Self-hosted installations that never set the variable or used the switch will create new accounts as pending after updating; existing accounts are unchanged. The self-hosting guide gets an upgrade note. Tests drive the real BetterAuth user-create hook and the MCP token gate with the variable unset; they fail against the old default. Tests that modelled an opted-out installation now set REQUIRE_APPROVAL=false or a runtime "off" row explicitly. Docs, .env.example, CLAUDE.md, the blog authoring guide and yesterday's WIF journal post stop saying approval is off by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chains the real user.create.before hook (REQUIRE_APPROVAL unset, Miniflare D1) into the real session.create.before election and asserts the pending first account becomes an active superadmin. Addresses security review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses Codex review on #2919. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mocked BetterAuth session user had no status. With signup approval on by default, a statusless non-admin is held for approval, so the proxy returned 403. Real user rows always carry status; the mock now says active. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
832c77e to
7529cd3
Compare
|



Summary
envRequiresApproval()(apps/api/src/services/signup-approval.ts) returnedenv.REQUIRE_APPROVAL === 'true'. That meant an installation that never set the variable gave an active account to anyone who could sign in. It now returns true unless the value isfalse(trimmed, case-insensitive). Unset values and typos keep approval on, so it fails closed.getSignupApprovalConfig). The first real account is still promoted to an active superadmin byestablishFirstSuperadmin(role='superadmin', status='active'), so a fresh install does not lock its owner out. The installerBOOTSTRAP_OWNER_EMAILpath is untouched.REQUIRE_APPROVAL=trueas GitHub Environment variables (checked withgh variable list --env production|staging), so their behaviour does not change.self-hosting.mdxgets an upgrade note.configuration.md(default column and description),self-hosting.mdx(the default, how to opt out, the upgrade note),installer.mdxand.env.examplenow say approval is on by default. RootCLAUDE.md, the blog authoring guide, and yesterday's WIF journal post (docs: frame SAM as self-hosted, not SaaS (WIF journal post + agent instructions) #2909) no longer say approval is off by default.Validation
pnpm --filter @simple-agent-manager/api typecheck: passedtests/unit/services/,tests/unit/routes/,tests/unit/auth.test.ts,tests/integration/agent-sign-in.test.ts): 10,623 passed, 3 skipped, after the fixes belowsignup-approval-gate,superadmin-self-heal,owner-session-snapshot-export: 106/106 passed. CI runs the full Workers suite.Test api (1/3)failure wasworkspace-proxy-ownership.test.ts: its mocked session user had nostatus, so the new default held it for approval. Real user rows always carry a status, so the mock now hasstatus: 'active'(7529cd3). The full local API unit suite then passed: 16,110 tests.'',yes, the typoflase, the real BetterAuthuser.create.beforehook creating a pending account with the variable unset, and the MCP token gate rejecting a pending owner with the variable unset.' FALSE 'is the opt-out control and passes either way.mcp-token-lifecycle.test.ts: the base env setsREQUIRE_APPROVAL: 'false'.platform-config-cache.test.ts: the test starts from an explicit runtime "off" row before checking that turning approval on is not cached.superadmin-self-healtest name no longer says "open registration".pnpm quality:agent-context-budget --check: passes. Prettier is clean on every changed file that was clean onmain.Staging Verification (REQUIRED for all code changes — merge-blocking)
Waived by Raphaël for this PR ("No need to test in staging… Get it into prod now", 2026-11-20). Also, the canonical staging environment already runs with
REQUIRE_APPROVAL=true, so a staging deploy would not exercise the changed default. The changed path, a variable that is unset, is covered by the tests above, which go through the real BetterAuth hook and MCP gate.UI Compliance Checklist (Required for UI changes)
N/A: no app UI changed.
End-to-End Verification (Required for multi-component changes)
N/A: one function's default changed, in a single component. Every reader goes through
envRequiresApproval:getSignupApprovalConfig→isSignupApprovalRequired(BetterAuthuser.create.beforeinauth.ts,assertSessionUserApproved)signupApprovalRequiredFromStoredValue(MCP token lifecycle)Both paths are tested with the variable unset.
Post-Mortem (Required for bug fix PRs)
What broke
A self-hosted installation with no
REQUIRE_APPROVALset used open registration. Anyone who could reach its sign-in got an active account.Root cause
The default was "off unless
true". The maintainers' own environments set the variable explicitly, so the open default was never seen in daily use.Class of bug
Fail-open default on an access gate, hidden by explicit configuration in the environments the maintainers use.
Process fix
Tests now pin the unset case through the real entry points, so a regression to fail-open breaks CI.
Specialist Review Evidence
needs-human-reviewlabel added and merge deferred to human (N/A so far)user.create.beforehook (variable unset) into the realsession.create.beforeelection and asserts active superadmin. LOW, not acted on: routes usingrequireAuthwithoutrequireApprovedare reachable by pending accounts. That is the documented pending-account surface (sign in, see the waiting state, link a GitHub App installation), and canonical production has run with approval on since February. Operator scripts that insert active users bypass the hook, which is intended. Two simultaneous first sign-ups leave no admin, which is pre-existing and not made worse.CodeRabbit Review Evidence
coderabbit-reviewlabel at 00:20 UTC; request workflow passed)Review skipped, which ends the wait (rule 25)CodeRabbit Notes
No review:
Review skipped. Nothing is unresolved.Other review bots
Codex (P1, fixed in 832c77e, resolved): the docs claimed the new default without citing code.
installer.mdx, theconfiguration.mdrow and.env.examplenow citeenvRequiresApproval. Codex's re-review of 832c77e reports no unresolved findings.Agent Preflight (Required)
Classification
External References
None. The change uses no external API.
Codebase Impact Analysis
Readers of the default:
envRequiresApproval(signup-approval.ts), used bygetSignupApprovalConfig,isSignupApprovalRequiredandsignupApprovalRequiredFromStoredValueauth.tsuser.create.beforemcp-token-lifecycle.tsNot affected: first-user election (
first-superadmin.ts, which sets active), the installer owner path (bootstrapUserDecision), and the admin runtime switch (routes/admin.ts,setSignupApprovalConfig).Deploy wiring:
REQUIRE_APPROVALis forwarded from GitHub Environment variables indeploy-reusable.ymlandsync-wrangler-config.ts, and that is unchanged. Production and staging already set it totrue.Documentation & Specs
configuration.md,self-hosting.mdx(default, opt-out and upgrade note),installer.mdx,.env.example, rootCLAUDE.md,apps/www/src/content/CLAUDE.md, and the WIF journal post. No specs touched.Constitution & Risk Check
Principle XI: the value stays configurable (environment variable plus runtime switch); only the default changes, to fail closed. Risk: self-hosters who rely on open signup must opt out after updating. This is documented in the upgrade note.
🤖 Generated with Claude Code