Skip to content

fix: make captcha and the waitlist work from the stock sign-up forms - #176

Merged
juicycleff merged 6 commits into
mainfrom
fix/captcha-json-body
Nov 14, 2026
Merged

juicycleff merged 6 commits into
mainfrom
fix/captcha-json-body

Conversation

@juicycleff

Copy link
Copy Markdown
Contributor

With auth.captcha_required on and the waitlist plugin registered, nobody can sign up or sign in through the stock UI. There are three separate bugs here, each with a regression test that fails without the fix.

What changed

  1. The captcha middleware only read the X-Captcha-Token header and form fields. The UI client posts JSON with captcha_token in the body, which is also what the request schema documents, so every request came back captcha_required. It now reads the token from a JSON body up to 64 KB and puts the bytes back. A new test binds a typed request behind the middleware to prove the handler still gets the whole body.
  2. The waitlist routes used engine.BasePath() as a prefix on a router that's already grouped at the base path, so they landed on /authsome/authsome/waitlist/join while the client posts to /v1/waitlist/join. agentauth got the same fix earlier. The join also ignored the app the publishable-key middleware puts on the context (middleware.AppIDFrom), so a join carrying only the key failed with "unable to determine app_id". An explicit app_id still wins, so the admin routes behave as before.
  3. The sign-in and sign-up forms rendered the Turnstile widget with no action, while the server binds each route to signin or signup. A real token never matched and came back captcha_invalid.

api/delegated_plugin_admin_test.go built its path from eng.BasePath(), so it encoded the doubled path. It uses /v1/admin/waitlist/... now.

Testing

  • go test ./middleware/... ./plugins/... ./api/... ./captcha/... ./extension/...
  • ui/packages/components: vitest (103 passing) and tsc --noEmit
  • End to end from Wakflo against a dev stack: a JSON-body token reaches the verifier, and a waitlist join with only the publishable key lands as pending.

Release

Wakflo is waiting on this. It needs a Go release and a publish of @authsome/ui-components.

Two follow-ups we noticed but left out of this PR: captcha.verify audit events fail with "chronicle: invalid query: resource is required", and a BeforeSignUp refusal surfaces to the client as a 500.

The UI client posts sign-up and sign-in as JSON with captcha_token in the
body, which is also what the request schema documents. The middleware only
looked at the X-Captcha-Token header and form fields, so every request from
the stock forms came back captcha_required.

It now reads the token from a JSON body up to 64 KB and puts the bytes
back, so the handler binds the request exactly as it arrived.
Two things kept the sign-up form's waitlist step from working on a mounted
engine.

The routes took engine.BasePath() as a prefix on a router that is already
grouped at the base path, so they landed on /authsome/authsome/waitlist/join
while the client posts to /v1/waitlist/join. agentauth had the same bug and
uses "/v1"; so does this now.

The join also read only forge's app scope, not the app the publishable-key
middleware puts on authsome's context. A join carrying nothing but the key
failed with "unable to determine app_id". An explicit app_id still wins.
The server binds sign-up's captcha to "signup" and sign-in's to "signin"
and refuses a token issued for anything else. The forms rendered the widget
with no action, so a real token never matched and every submission came
back captcha_invalid.
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
middleware/captcha.go 82.60% 2 Missing and 2 partials ⚠️
plugins/mfa/plugin.go 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

juicycleff and others added 3 commits November 13, 2026 17:20
- organization: check the notification plugin type assertion, name
  authorizeInvitationChange's results, drop an unused test return
- mfa: stop shadowing err in the SMS override path, group imports in
  two tests, drop an ineffectual assignment and two always-same test
  parameters
- middleware: blank the unused handler context in the captcha test
- gitleaks: allowlist the fake password in the captcha JSON-body test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rollback only ever reverses the newest migration. Since
add_invitation_sent_at and add_session_mfa_verified_at landed, a single
Rollback undid those instead of api_key_machine_owners, so both downgrade
tests stopped reaching its Down: the guard never raised and the
ACCESS EXCLUSIVE lock the race test waits for never appeared.

The tests now roll back every migration applied after
api_key_machine_owners first, so they keep exercising its Down as later
migrations land.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juicycleff
juicycleff merged commit e76968f into main Nov 14, 2026
22 checks passed
@juicycleff
juicycleff deleted the fix/captcha-json-body branch November 14, 2026 00:35
juicycleff added a commit that referenced this pull request Nov 14, 2026
Both sides cleared the same golangci-lint findings in plugins/mfa; keep
main's versions, which landed with #176.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant