Draft
Conversation
f5ea3a6 to
8acc811
Compare
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
Adds Cap as a fourth supported captcha provider
(
CAPTCHA_PROVIDER=cap), alongside the existingrecaptcha,hcaptchaandturnstile.Cap is a self-hosted, privacy-friendly proof-of-work captcha:
Files changed
lib/plugins/crowdsec/captcha.luacapto the three lookup tables; addValidateCap()(JSON POST instead of form-encoded); dispatch inValidate(); accept two new optional params inNew()lib/crowdsec.luaCAPTCHA_VERIFY_URLandCAPTCHA_JS_URLtocaptcha.New()— one line changedconfig_example.confcrowdsec.luaalready passesCAPTCHA_PROVIDERtocaptcha.New(), so theprovider dispatch required no structural changes there.
New configuration keys
Only read when
CAPTCHA_PROVIDER=cap. Existing configurations are unaffected.How Cap validation differs from the other providers
The three existing providers (recaptcha, hcaptcha, turnstile) all use the same
protocol: a form-encoded POST to a third-party HTTPS endpoint that returns
{"success": true/false}.Cap uses a JSON POST to a self-hosted endpoint. The new
ValidateCap()function handles this; the existing
Validate()path is unchanged.Template
The existing
captcha.htmltemplate is already rendered withcaptcha_frontend_js,captcha_frontend_keyandcaptcha_site_keyplaceholders. For Cap, those resolve to:
captcha_frontend_jsCAPTCHA_JS_URLcaptcha_frontend_keycapcaptcha_site_keySITE_KEYA minimal working template snippet for Cap:
Checklist
crowdsec.luapassesnilfor the new params if keys are absent from config)GetCaptchaBackendKey()returnscap-responsefor the Cap provider, consistent with the form field nameconfig_example.confcomment updated (#valid providers are recaptcha, hcaptcha, turnstile, cap)