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

Signup verifies a Turnstile token on the server before it makes an account, through a verifier injected on createApp #1673

Closed opened this
Closed without merging

Signup now checks a Turnstile token on the server before it hashes a password or makes an account. It only does so when FORGETURNSTILESECRET is set. With no secret, signup behaves as before.

Notes

stopped closed without shipping deploy e0945d5

opened this

Signup now checks a Turnstile token on the server before it hashes a password or makes an account. It only does so when FORGE_TURNSTILE_SECRET is set. With no secret, signup behaves as before. No code changed this round: the branch is already pushed, and the earlier red check is not caused by this change.

The red check: test/home-feed.test.ts › "On you can be cleared in one move: a box each, select all, by kind and by repository, one form" fails the same way on main. I ran it three times on this branch and once on main; each run was 6 pass, 1 fail. This pull doesn't touch the home feed, so I left it alone. It needs its own issue.

Checks on this branch:

  • bun x tsc --noEmit is clean.
  • bun test test/turnstile.test.ts test/check-list.test.ts gives 12 pass, 0 fail.
  • The earlier run of test/accounts.test.ts also passed.

What changed:

  • Verifier: src/turnstile.ts posts the secret, token and client address to Cloudflare's siteverify. Anything other than success: true counts as no.
  • Injection: createApp takes verifyHuman. src/main.ts builds it from FORGE_TURNSTILE_SECRET, so the secret never goes in the repository. Tests inject a fake.
  • Refusal: with a verifier set, signUp returns human_check_failed before createUser runs. The web form reads cf-turnstile-response and shows "We could not tell you are a person. Try again." POST /api/v1/users reads the same key and returns 422.
  • Tests: test/turnstile.test.ts is listed in GATE in the same commit. It covers off → signup works, on with a good token → account made, and on with a missing, empty or bad token → refused with zero rows in user. It also covers the verifier's request body and its no on a failed reply, a 500, an empty token or a network error.

Left out:

  • Widget: the signup page has no Turnstile widget, because the issue is server side only. With a secret set, web signup is refused until a later change adds it.
  • Terminal signup: it has no token to send, so it is refused too once a secret is set.
  • First account: it is not exempt from the check.

To try it: set FORGE_TURNSTILE_SECRET. Cloudflare's documented test secrets let you exercise it without a real widget.

🤖 Generated with Claude Code

Closes #1665

commented

Parked by the crew: the check failed ("home is the feed > On you can be cleared in one move: a box each, select all, by kind and by repository, one form") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs