From 408ac8bd6476f19fa448b1a0c6208aef41774fe1 Mon Sep 17 00:00:00 2001 From: Laurence Date: Tue, 7 Mar 2023 15:18:02 +0000 Subject: [PATCH 01/15] Add option for another captcha providers (hcaptcha, turnstile) --- config_example.conf | 2 ++ lib/crowdsec.lua | 33 ++++++++++++++++------------- lib/plugins/crowdsec/config.lua | 7 +++--- lib/plugins/crowdsec/recaptcha.lua | 34 ++++++++++++++++++++++++------ templates/captcha.html | 4 ++-- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/config_example.conf b/config_example.conf index f1e7c44..22e47ee 100644 --- a/config_example.conf +++ b/config_example.conf @@ -17,6 +17,8 @@ BAN_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/ban.html REDIRECT_LOCATION= RET_CODE= #those apply for "captcha" action +#valid providers are recaptcha, hcaptcha, turnstile +CAPTCHA_PROVIDER= # ReCaptcha Secret Key SECRET_KEY= # Recaptcha Site key diff --git a/lib/crowdsec.lua b/lib/crowdsec.lua index cf62d31..165c4d9 100644 --- a/lib/crowdsec.lua +++ b/lib/crowdsec.lua @@ -4,7 +4,7 @@ local config = require "plugins.crowdsec.config" local iputils = require "plugins.crowdsec.iputils" local http = require "resty.http" local cjson = require "cjson" -local recaptcha = require "plugins.crowdsec.recaptcha" +local captcha = require "plugins.crowdsec.recaptcha" local utils = require "plugins.crowdsec.utils" local ban = require "plugins.crowdsec.ban" @@ -43,9 +43,9 @@ function csmod.init(configFile, userAgent) end local captcha_ok = true - local err = recaptcha.New(runtime.conf["SITE_KEY"], runtime.conf["SECRET_KEY"], runtime.conf["CAPTCHA_TEMPLATE_PATH"]) + local err = captcha.New(runtime.conf["SITE_KEY"], runtime.conf["SECRET_KEY"], runtime.conf["CAPTCHA_TEMPLATE_PATH"], runtime.conf["CAPTCHA_PROVIDER"]) if err ~= nil then - ngx.log(ngx.ERR, "error loading recaptcha plugin: " .. err) + ngx.log(ngx.ERR, "error loading captcha plugin: " .. err) captcha_ok = false end local succ, err, forcible = runtime.cache:set("captcha_ok", captcha_ok) @@ -89,8 +89,8 @@ function csmod.init(configFile, userAgent) end -function csmod.validateCaptcha(g_captcha_res, remote_ip) - return recaptcha.Validate(g_captcha_res, remote_ip) +function csmod.validateCaptcha(captcha_res, remote_ip) + return captcha.Validate(captcha_res, remote_ip) end @@ -364,9 +364,12 @@ end function csmod.GetCaptchaTemplate() - return recaptcha.GetTemplate() + return captcha.GetTemplate() end +function csmod.GetCaptchaBackendKey() + return captcha.GetCaptchaBackendKey() +end function csmod.SetupStream() -- if it stream mode and startup start timer @@ -464,7 +467,7 @@ function csmod.Allow(ip) local captcha_ok = runtime.cache:get("captcha_ok") if runtime.fallback ~= "" then - -- if we can't use recaptcha, fallback + -- if we can't use captcha, fallback if remediation == "captcha" and captcha_ok == false then remediation = runtime.fallback end @@ -478,17 +481,17 @@ function csmod.Allow(ip) if captcha_ok then -- if captcha can be use (configuration is valid) -- we check if the IP need to validate its captcha before checking it against crowdsec local API local previous_uri, state_id = ngx.shared.crowdsec_cache:get("captcha_"..ngx.var.remote_addr) - if previous_uri ~= nil and state_id == recaptcha.GetStateID(recaptcha._VERIFY_STATE) then + if previous_uri ~= nil and state_id == captcha.GetStateID(captcha._VERIFY_STATE) then ngx.req.read_body() - local recaptcha_res = ngx.req.get_post_args()["g-recaptcha-response"] or 0 - if recaptcha_res ~= 0 then - local valid, err = csmod.validateCaptcha(recaptcha_res, ngx.var.remote_addr) + local captcha_res = ngx.req.get_post_args()[csmod.GetCaptchaBackendKey()] or 0 + if captcha_res ~= 0 then + local valid, err = csmod.validateCaptcha(captcha_res, ngx.var.remote_addr) if err ~= nil then ngx.log(ngx.ERR, "Error while validating captcha: " .. err) end if valid == true then -- captcha is valid, we redirect the IP to its previous URI but in GET method - local succ, err, forcible = ngx.shared.crowdsec_cache:set("captcha_"..ngx.var.remote_addr, previous_uri, runtime.conf["CAPTCHA_EXPIRATION"], recaptcha.GetStateID(recaptcha._VALIDATED_STATE)) + local succ, err, forcible = ngx.shared.crowdsec_cache:set("captcha_"..ngx.var.remote_addr, previous_uri, runtime.conf["CAPTCHA_EXPIRATION"], captcha.GetStateID(captcha._VALIDATED_STATE)) if not succ then ngx.log(ngx.ERR, "failed to add key about captcha for ip '" .. ngx.var.remote_addr .. "' in cache: "..err) end @@ -500,7 +503,7 @@ function csmod.Allow(ip) ngx.redirect(previous_uri) return else - ngx.log(ngx.ALERT, "Invalid captcha from " .. ngx.var.remote_addr) + ngx.log(ngx.ALERT, "Invalidaptcha from " .. ngx.var.remote_addr) end end end @@ -516,7 +519,7 @@ function csmod.Allow(ip) if remediation == "captcha" and captcha_ok and ngx.var.uri ~= "/favicon.ico" then local previous_uri, state_id = ngx.shared.crowdsec_cache:get("captcha_"..ngx.var.remote_addr) -- we check if the IP is already in cache for captcha and not yet validated - if previous_uri == nil or state_id ~= recaptcha.GetStateID(recaptcha._VALIDATED_STATE) then + if previous_uri == nil or state_id ~= captcha.GetStateID(captcha._VALIDATED_STATE) then ngx.header.content_type = "text/html" ngx.say(csmod.GetCaptchaTemplate()) local uri = ngx.var.uri @@ -529,7 +532,7 @@ function csmod.Allow(ip) end end end - local succ, err, forcible = ngx.shared.crowdsec_cache:set("captcha_"..ngx.var.remote_addr, uri , 60, recaptcha.GetStateID(recaptcha._VERIFY_STATE)) + local succ, err, forcible = ngx.shared.crowdsec_cache:set("captcha_"..ngx.var.remote_addr, uri , 60, captcha.GetStateID(captcha._VERIFY_STATE)) if not succ then ngx.log(ngx.ERR, "failed to add key about captcha for ip '" .. ngx.var.remote_addr .. "' in cache: "..err) end diff --git a/lib/plugins/crowdsec/config.lua b/lib/plugins/crowdsec/config.lua index ac0f9c2..54f423f 100644 --- a/lib/plugins/crowdsec/config.lua +++ b/lib/plugins/crowdsec/config.lua @@ -40,7 +40,7 @@ function config.loadConfig(file) return nil, "File ".. file .." doesn't exist" end local conf = {} - local valid_params = {'ENABLED','API_URL', 'API_KEY', 'BOUNCING_ON_TYPE', 'MODE', 'SECRET_KEY', 'SITE_KEY', 'BAN_TEMPLATE_PATH' ,'CAPTCHA_TEMPLATE_PATH', 'REDIRECT_LOCATION', 'RET_CODE', 'EXCLUDE_LOCATION', 'FALLBACK_REMEDIATION'} + local valid_params = {'ENABLED','API_URL', 'API_KEY', 'BOUNCING_ON_TYPE', 'MODE', 'SECRET_KEY', 'SITE_KEY', 'BAN_TEMPLATE_PATH' ,'CAPTCHA_TEMPLATE_PATH', 'REDIRECT_LOCATION', 'RET_CODE', 'EXCLUDE_LOCATION', 'FALLBACK_REMEDIATION', 'CAPTCHA_PROVIDER'} local valid_int_params = {'CACHE_EXPIRATION', 'CACHE_SIZE', 'REQUEST_TIMEOUT', 'UPDATE_FREQUENCY', 'CAPTCHA_EXPIRATION'} local valid_bouncing_on_type_values = {'ban', 'captcha', 'all'} local valid_truefalse_values = {'false', 'true'} @@ -53,7 +53,8 @@ function config.loadConfig(file) ['CAPTCHA_EXPIRATION'] = 3600, ['REDIRECT_LOCATION'] = "", ['EXCLUDE_LOCATION'] = {}, - ['RET_CODE'] = 0 + ['RET_CODE'] = 0, + ['CAPTCHA_PROVIDER'] = "recaptcha" } for line in io.lines(file) do local isOk = false @@ -130,4 +131,4 @@ function config.loadConfig(file) end return conf, nil end -return config \ No newline at end of file +return config diff --git a/lib/plugins/crowdsec/recaptcha.lua b/lib/plugins/crowdsec/recaptcha.lua index cfe0fc1..c07afa6 100644 --- a/lib/plugins/crowdsec/recaptcha.lua +++ b/lib/plugins/crowdsec/recaptcha.lua @@ -6,7 +6,20 @@ local utils = require "plugins.crowdsec.utils" local M = {_TYPE='module', _NAME='recaptcha.funcs', _VERSION='1.0-0'} -local recaptcha_verify_url = "https://www.google.com/recaptcha/api/siteverify" +local captcha_backend_url = {} +captcha_backend_url["recaptcha"] = "https://www.google.com/recaptcha/api/siteverify" +captcha_backend_url["hcaptcha"] = "https://hcaptcha.com/siteverify" +captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/siteverify" + +local captcha_frontend_js = {} +captcha_backend_url["recaptcha"] = "https://www.google.com/recaptcha/api.js" +captcha_backend_url["hcaptcha"] = "https://js.hcaptcha.com/1/api.js" +captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/api.js" + +local captcha_frontend_key = {} +captcha_frontend_key["recaptcha"] = "g-recaptcha" +captcha_frontend_key["hcaptcha"] = "h-captcha" +captcha_frontend_key["turnstile"] = "cf-turnstile" M._VERIFY_STATE = "to_verify" M._VALIDATED_STATE = "validated" @@ -32,7 +45,7 @@ end -function M.New(siteKey, secretKey, TemplateFilePath) +function M.New(siteKey, secretKey, TemplateFilePath, captcha_provider) if siteKey == nil or siteKey == "" then return "no recaptcha site key provided, can't use recaptcha" @@ -57,8 +70,12 @@ function M.New(siteKey, secretKey, TemplateFilePath) return "Template file " .. TemplateFilePath .. "not found." end + M.CaptchaProvider = captcha_provider + local template_data = {} - template_data["recaptcha_site_key"] = M.SiteKey + template_data["captcha_site_key"] = M.SiteKey + template_data["captcha_frontend_js"] = captcha_frontend_js[M.CaptchaProvider] + template_data["captcha_frontend_key"] = captcha_frontend_key[M.CaptchaProvider] local view = template.compile(captcha_template, template_data) M.Template = view @@ -70,6 +87,9 @@ function M.GetTemplate() return M.Template end +function M.GetCaptchaBackendKey() + return captcha_frontend_key[M.CaptchaProvider] .. "-response" +end function table_to_encoded_url(args) local params = {} @@ -77,17 +97,17 @@ function table_to_encoded_url(args) return table.concat(params, "&") end -function M.Validate(g_captcha_res, remote_ip) +function M.Validate(captcha_res, remote_ip) local body = { secret = M.SecretKey, - response = g_captcha_res, + response = captcha_res, remoteip = remote_ip } local data = table_to_encoded_url(body) local httpc = http.new() httpc:set_timeout(2000) - local res, err = httpc:request_uri(recaptcha_verify_url, { + local res, err = httpc:request_uri(captcha_backend_url[M.CaptchaProvider], { method = "POST", body = data, headers = { @@ -114,4 +134,4 @@ function M.Validate(g_captcha_res, remote_ip) end -return M \ No newline at end of file +return M diff --git a/templates/captcha.html b/templates/captcha.html index 6e6068a..7922331 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -76,7 +76,7 @@ } - + @@ -88,7 +88,7 @@

CrowdSec ReCaptcha
-
+

From c96ed4d71e3b032042aa6503046f25d4b09af1ad Mon Sep 17 00:00:00 2001 From: Laurence Date: Tue, 7 Mar 2023 15:30:53 +0000 Subject: [PATCH 02/15] Fix wrong map usage --- lib/plugins/crowdsec/recaptcha.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/plugins/crowdsec/recaptcha.lua b/lib/plugins/crowdsec/recaptcha.lua index c07afa6..afe915e 100644 --- a/lib/plugins/crowdsec/recaptcha.lua +++ b/lib/plugins/crowdsec/recaptcha.lua @@ -12,9 +12,9 @@ captcha_backend_url["hcaptcha"] = "https://hcaptcha.com/siteverify" captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/siteverify" local captcha_frontend_js = {} -captcha_backend_url["recaptcha"] = "https://www.google.com/recaptcha/api.js" -captcha_backend_url["hcaptcha"] = "https://js.hcaptcha.com/1/api.js" -captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/api.js" +captcha_frontend_js["recaptcha"] = "https://www.google.com/recaptcha/api.js" +captcha_frontend_js["hcaptcha"] = "https://js.hcaptcha.com/1/api.js" +captcha_frontend_js["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/api.js" local captcha_frontend_key = {} captcha_frontend_key["recaptcha"] = "g-recaptcha" From 2444d2c36d0b8cfd720bcd41eb8c1fbe493e2d52 Mon Sep 17 00:00:00 2001 From: Laurence Date: Wed, 8 Mar 2023 15:56:20 +0000 Subject: [PATCH 03/15] Update templates to mobile first and light/dark mode options --- templates/ban.html | 208 ++++++++++++++++----------------------- templates/captcha.html | 214 ++++++++++++++++------------------------- 2 files changed, 168 insertions(+), 254 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index 8110e2f..ced6f3c 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -3,137 +3,95 @@ CrowdSec Ban - + + - -
-
-

- -

CrowdSec Access Forbidden

-

You are unable to visit the website.

-

-

- This security check has been powered by - +

+
+
+
+ +

CrowdSec Access Forbidden

+

You are unable to visit the website.

+
+
+

+ This security check has been powered by +

+ + + + + + + + + + + - - + + + + + + - - - - CrowdSec -

+ + + CrowdSec + + +
+
- + diff --git a/templates/captcha.html b/templates/captcha.html index 7922331..1f9eb79 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -3,142 +3,98 @@ CrowdSec ReCaptcha - + + - - -
-
-

- - CrowdSec ReCaptcha -
-
-
- -
-

-

+ +

+
+
+
+ +

CrowdSec Captcha

+
+
+ +
+
+ + + + + + CrowdSec + +
- +
+
+ + From 0738655ae975c1eea35bc22d05f640259db9e795 Mon Sep 17 00:00:00 2001 From: Laurence Date: Wed, 8 Mar 2023 15:57:46 +0000 Subject: [PATCH 04/15] rename recaptcha to captcha more generic --- lib/crowdsec.lua | 2 +- lib/plugins/crowdsec/{recaptcha.lua => captcha.lua} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/plugins/crowdsec/{recaptcha.lua => captcha.lua} (100%) diff --git a/lib/crowdsec.lua b/lib/crowdsec.lua index 165c4d9..09d46f2 100644 --- a/lib/crowdsec.lua +++ b/lib/crowdsec.lua @@ -4,7 +4,7 @@ local config = require "plugins.crowdsec.config" local iputils = require "plugins.crowdsec.iputils" local http = require "resty.http" local cjson = require "cjson" -local captcha = require "plugins.crowdsec.recaptcha" +local captcha = require "plugins.crowdsec.captcha" local utils = require "plugins.crowdsec.utils" local ban = require "plugins.crowdsec.ban" diff --git a/lib/plugins/crowdsec/recaptcha.lua b/lib/plugins/crowdsec/captcha.lua similarity index 100% rename from lib/plugins/crowdsec/recaptcha.lua rename to lib/plugins/crowdsec/captcha.lua From dcbc57ab65f0bb816e88c7211c3d71756138a23a Mon Sep 17 00:00:00 2001 From: Laurence Date: Wed, 8 Mar 2023 16:16:01 +0000 Subject: [PATCH 05/15] Just one more update to show pointer cursor on submit button --- templates/ban.html | 2 +- templates/captcha.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index ced6f3c..beebc90 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -4,7 +4,7 @@ CrowdSec Ban - + diff --git a/templates/captcha.html b/templates/captcha.html index 1f9eb79..c53f0a7 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -4,12 +4,12 @@ CrowdSec ReCaptcha - +
-
+

CrowdSec Captcha

- +
From 2f30c63a2cce85d9522983cccdb385ea63cbb7d1 Mon Sep 17 00:00:00 2001 From: Laurence Date: Wed, 8 Mar 2023 16:19:59 +0000 Subject: [PATCH 06/15] height on mobile was out fixed --- templates/ban.html | 2 +- templates/captcha.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index beebc90..1659f1b 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -4,7 +4,7 @@ CrowdSec Ban - + diff --git a/templates/captcha.html b/templates/captcha.html index c53f0a7..b82d8c0 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -4,12 +4,12 @@ CrowdSec ReCaptcha - +
-
+
- CrowdSec ReCaptcha + CrowdSec Captcha From c255e8eac99e16baf443e2ef551b4e2a29bce13e Mon Sep 17 00:00:00 2001 From: Laurence Date: Wed, 8 Mar 2023 16:26:47 +0000 Subject: [PATCH 08/15] Make button same color dark and light mode easily to see --- templates/ban.html | 2 +- templates/captcha.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index 1659f1b..14adf4b 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -4,7 +4,7 @@ CrowdSec Ban - + diff --git a/templates/captcha.html b/templates/captcha.html index 275b3a8..b8169d3 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -4,7 +4,7 @@ CrowdSec Captcha - + @@ -15,10 +15,10 @@ -

CrowdSec Captcha

+

CrowdSec Captcha

- +
From 681f09067468e2f1100dfe021e09d083dfed1d21 Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 09:32:43 +0000 Subject: [PATCH 09/15] Add auto captcha submit on completion and increase height on ban template on mobile --- templates/ban.html | 4 ++-- templates/captcha.html | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index 14adf4b..25f15f8 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -4,12 +4,12 @@ CrowdSec Ban - +
-
+
- + @@ -16,9 +16,8 @@

CrowdSec Captcha

-
-
- + +
@@ -85,16 +84,18 @@

CrowdSec Captcha

button.addEventListener('click', function() { document.body.classList.toggle('dark'); svg.forEach(element => { - if (element.getAttribute('fill') === 'black') { - element.setAttribute('fill', 'white'); + element.getAttribute('fill') === 'black' ? element.setAttribute('fill', 'white') : element.setAttribute('fill', 'black'); + }); + if (document.body.classList.contains('dark')) { button.innerHTML = sunSvgString; } else { - element.setAttribute('fill', 'black'); button.innerHTML = moonSvgString; } - }); }); }; + function captchaCallback () { + document.querySelector('#captcha-form').submit(); + } From 8a397c8f9017ce1571b342296ded7c6eb351c798 Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 09:36:00 +0000 Subject: [PATCH 10/15] Fix typo --- lib/crowdsec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crowdsec.lua b/lib/crowdsec.lua index 09d46f2..bc8c81d 100644 --- a/lib/crowdsec.lua +++ b/lib/crowdsec.lua @@ -503,7 +503,7 @@ function csmod.Allow(ip) ngx.redirect(previous_uri) return else - ngx.log(ngx.ALERT, "Invalidaptcha from " .. ngx.var.remote_addr) + ngx.log(ngx.ALERT, "Invalid captcha from " .. ngx.var.remote_addr) end end end From c5806c69b95360af97644eb679c94bcf34fa295f Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 09:40:05 +0000 Subject: [PATCH 11/15] Fix dark mode button on ban --- templates/ban.html | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index 25f15f8..339778b 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -80,17 +80,16 @@

CrowdSec Access Forbidd button.innerHTML = moonSvgString; } button.addEventListener('click', function() { - document.body.classList.toggle('dark'); - svg.forEach(element => { - if (element.getAttribute('fill') === 'black') { - element.setAttribute('fill', 'white'); - button.innerHTML = sunSvgString; - } else { - element.setAttribute('fill', 'black'); - button.innerHTML = moonSvgString; - } - }); + document.body.classList.toggle('dark'); + svg.forEach(element => { + element.getAttribute('fill') === 'black' ? element.setAttribute('fill', 'white') : element.setAttribute('fill', 'black'); }); + if (document.body.classList.contains('dark')) { + button.innerHTML = sunSvgString; + } else { + button.innerHTML = moonSvgString; + } + }); }; From bee5e91bd82fdee54dcce0f99e66ef0047f8e14d Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 10:05:23 +0000 Subject: [PATCH 12/15] Add short timeout to make captcha smoother --- templates/captcha.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/captcha.html b/templates/captcha.html index 3f5f69a..237f5ab 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -94,7 +94,9 @@

CrowdSec Captcha

}); }; function captchaCallback () { - document.querySelector('#captcha-form').submit(); + setTimeout(() => { + document.querySelector('#captcha-form').submit(); + }, 1000); } From bbb985cf496c386af4d4628012b1d0206a8f533b Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 10:06:12 +0000 Subject: [PATCH 13/15] half timeout to make captcha smoother --- templates/captcha.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/captcha.html b/templates/captcha.html index 237f5ab..e9e5362 100644 --- a/templates/captcha.html +++ b/templates/captcha.html @@ -96,7 +96,7 @@

CrowdSec Captcha

function captchaCallback () { setTimeout(() => { document.querySelector('#captcha-form').submit(); - }, 1000); + }, 500); } From 81c7f572923509f702806a880610bf6eb5bb35e5 Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 9 Mar 2023 21:43:53 +0000 Subject: [PATCH 14/15] Fix the things I noticed when updating the haproxy bouncer --- config_example.conf | 4 ++-- lib/plugins/crowdsec/captcha.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config_example.conf b/config_example.conf index 22e47ee..e99e4b2 100644 --- a/config_example.conf +++ b/config_example.conf @@ -19,9 +19,9 @@ RET_CODE= #those apply for "captcha" action #valid providers are recaptcha, hcaptcha, turnstile CAPTCHA_PROVIDER= -# ReCaptcha Secret Key +# Captcha Secret Key SECRET_KEY= -# Recaptcha Site key +# Captcha Site key SITE_KEY= CAPTCHA_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/captcha.html CAPTCHA_EXPIRATION=3600 diff --git a/lib/plugins/crowdsec/captcha.lua b/lib/plugins/crowdsec/captcha.lua index afe915e..8968b07 100644 --- a/lib/plugins/crowdsec/captcha.lua +++ b/lib/plugins/crowdsec/captcha.lua @@ -7,12 +7,12 @@ local utils = require "plugins.crowdsec.utils" local M = {_TYPE='module', _NAME='recaptcha.funcs', _VERSION='1.0-0'} local captcha_backend_url = {} -captcha_backend_url["recaptcha"] = "https://www.google.com/recaptcha/api/siteverify" +captcha_backend_url["recaptcha"] = "https://www.recaptcha.net/recaptcha/api/siteverify" captcha_backend_url["hcaptcha"] = "https://hcaptcha.com/siteverify" captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/siteverify" local captcha_frontend_js = {} -captcha_frontend_js["recaptcha"] = "https://www.google.com/recaptcha/api.js" +captcha_frontend_js["recaptcha"] = "https://www.recaptcha.net/recaptcha/api.js" captcha_frontend_js["hcaptcha"] = "https://js.hcaptcha.com/1/api.js" captcha_frontend_js["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/api.js" From 86261fe1ced83eb05f233b496a7961204018a60a Mon Sep 17 00:00:00 2001 From: Laurence Date: Fri, 10 Mar 2023 15:15:35 +0000 Subject: [PATCH 15/15] Fix light mode on load within templates --- templates/ban.html | 4 ++-- templates/captcha.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/ban.html b/templates/ban.html index 339778b..7c13af1 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -12,7 +12,7 @@
-

CrowdSec Access Forbidden

@@ -24,7 +24,7 @@

CrowdSec Access Forbidd