Repository navigation
Conversation
Adds three new validation types alongside none and pow, backed by one shared captcha validator. The challenge GET serves a static per-level body carrying the sitekey; the POST exchanges the widget response token for a cookie after verifying it against the provider siteverify endpoint (fail closed) and binding the reported hostname to the request identity, accepting subdomains since trusted_domains may collapse the identity host to a suffix. The web protocol type numbering skips t:2, which the challenge page capability checks already reserve for a worker-based POW. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Provider test keys report a fixed hostname unrelated to the page, so tests cannot pass the hostname binding. Adds an explicit opt-out for captcha levels, documented as test-only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 11, 2026
Member
Author
|
Consolidated into #78. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of three PRs adding captcha challenge types (plan: server → web → integration/e2e).
Adds
turnstile,hcaptcha, andrecaptcha(v2 checkbox) as additional validation types alongsidenoneandpow, backed by one sharedvalidator_captcha.gosince all three providers use the same sitekey → widget token → siteverify flow.{"c","t","k"}with the sitekey, precomputed on first use (no per-request state needed — security binding stays in the existing cookie HMAC).secret/response/remoteip), requiressuccessand a hostname match against the request identity (subdomains accepted, sincetrusted_domainsmay collapse the identity host to a suffix), then issues the cookie via the existingToCookie.Berghain.HTTPClient(5s default timeout, injectable) — this is the first validator doing network I/O; the hotvalidatepath is untouched.type: turnstile|hcaptcha|recaptcha+sitekey/secret(+ optionalverify_urloverride), validated at startup withFatallike the existing countdown check.t:2, which the challenge page capability checks already reserve for worker-based POW; captcha types aret:3/4/5.The browser side (widget rendering for
t:3–5) and the HAProxy example timeout split land in follow-up PRs.Test plan
go test ./...— new tests cover GET body shape, POST happy path against an httptest siteverify stub (asserting all form fields), subdomain hostname match, rejected token, hostname mismatch, provider 5xx + dead provider (fail closed), empty/oversized bodies, and a hostname-matching table test.go vet+ staticcheck v0.6.1 (CI version) clean.cmd/spopwith the updated example config (turnstile level with Cloudflare dummy keys) — starts and listens; a captcha level missing its secret refuses to start with a clear error.🤖 Generated with Claude Code