Public: anyone can read this; the crew can change it.

The owner can close signup: one live setting, open or closed, kept on every way an account is made #1154

Parked opened this
Closed without merging

A forge admin can now close signup live, and /signup, POST /api/v1/users and edge first-sight accounts all obey it. The new test file and the capacity, guard-new-accounts, edge-auth, first-login and accounts tests pass, and tsc printed nothing. I did not run the whole suite.

Notes

stopped parked by the crew deploy 9ba37ed

opened this

A forge admin can now close signup live, and /signup, POST /api/v1/users and edge first-sight accounts all obey it. The new test file and the capacity, guard-new-accounts, edge-auth, first-login and accounts tests pass, and tsc printed nothing. I did not run the whole suite. The test run needed the sandbox switched off, because it blocked the unix socket the server listens on.

What changed

  • The setting: signup is a new key in the existing capacity settings (src/core/capacity.ts), with values open | invite | closed and a default of open. invite is stored and acts like closed.
  • Where it changes: Settings → Capacity, the capacity MCP tool, and the new PATCH /api/v1/admin/settings. The PATCH body is {"signup": "closed"}, needs an admin-scope token, and checks every key and value before applying any. The setting is read on every attempt, so no restart is needed.
  • Boot: FORGE_SIGNUP sets it at boot. A wrong word makes the boot fail in src/main.ts, like FORGE_TRUSTED_PROXIES.
  • When closed:
    • /signup (GET and POST) returns 403 with "Signup is closed on this forge."
    • POST /api/v1/users returns 403 signup_closed with that sentence.
    • ensureEdgeUser makes no new account, though existing edge users still get in.
    • The TUI sign-up goes through the same check.
  • First account: a forge with no users always lets the first account in, whatever the setting says. Sign-in and existing sessions don't read the setting.
  • Audit: each change writes a capacity.changed event and a row in the change history with who, when, and from what to what. I did not add a separate audit trail.
  • Tests and docs: test/signup-closed.test.ts covers each mode on the page, the API and the edge, the first-account exception, a live change by PATCH, refusal of wrong values and non-admins, and the audit row. The README mentions FORGE_SIGNUP.

Left out

  • invite has no behaviour of its own, as the issue says.
  • Setting FORGE_SIGNUP=closed on a forge that already has users takes effect from boot, as intended.
  • I did not hide the "Sign up" link on the sign-in page when closed. It leads to the closed message.

To try it: boot with FORGE_SIGNUP=closed bun run src/main.ts, or sign in as admin and use Settings → Capacity → "Who can sign up".

🤖 Generated with Claude Code

Closes #1142

commented

I merged main into this branch, resolved the five conflicts, and pushed. The type check is clean. I did not run the whole test suite. I ran signup-closed, signup-passkey and capacity, and they pass.

The capacity test fails here only because this sandbox sets FORGE_CHECK_SHARDS=4, which isn't from the merge. With it cleared, capacity passes.

What changed

  • Sign-up error: signUp now returns signup_closed alongside human_check and passkey_required. It checks the open/closed setting first, before the Turnstile check or any password hashing.
  • API sign-up: POST sign-up answers 403 signup_closed when closed. It keeps the 422 answers for passkey_required and human_check.
  • Sign-up page: a closed /signup shows the closed page (403). The form handler also checks the setting, and shows the closed message if the error comes back anyway.
  • Capacity and admin API: the signup setting and signupOpen sit alongside children.max in src/core/capacity.ts. PATCH /api/v1/admin/settings sits alongside the new limits routes in src/http/api.ts.
  • Boot check: src/main.ts keeps the FORGE_SIGNUP word check and the new drain-linger check.
  • Test typing: I added a type cast in test/signup-closed.test.ts so it type-checks.
commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs