Add captchas module: generic captcha abstraction with Turnstile, hCaptcha, and reCAPTCHA v2/v3#15
Open
lk316 wants to merge 19 commits into
Open
Add captchas module: generic captcha abstraction with Turnstile, hCaptcha, and reCAPTCHA v2/v3#15lk316 wants to merge 19 commits into
lk316 wants to merge 19 commits into
Conversation
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.
All 4 providers in a single module as they are not complicated which means we can avoid the module cross-dependency dance.
pos-module-captchas
New module: a generic, swappable captcha abstraction. It does two jobs behind one uniform interface:
render 'modules/captchas/widget', provider: ..., site_key: ...emits the provider's loader script + widget element (script deduped per page, options passed through, all attribute output escaped).function r = 'modules/captchas/commands/captcha/verify', secret: ...runs build > check > execute, POSTs the token to the provider's siteverify endpoint viaapi_call_send, and returns a normalized{ valid, success, response, errors }.Providers
expected_sitekeyto bind tokens to one sitekey (hCaptcha secrets are account-wide).size: invisibledocumented as requiring caller JS.min_score(default 0.5) and optionalexpected_action; invisible widget auto-injects the token on submit.Design notes
expected_hostnameallow-list as defense-in-depth.CAPTCHA_DEFAULT_PROVIDERconstant.Testing
pos-cli test run./captcha-demo?provider=...>/captcha-verify, using each provider's public always-pass test keys (v3 needs real keys via constants).pos-cli checkclean.