diff --git a/crates/cli/src/util.rs b/crates/cli/src/util.rs index 02520fc4..7c35ec03 100644 --- a/crates/cli/src/util.rs +++ b/crates/cli/src/util.rs @@ -132,6 +132,7 @@ pub fn captcha_config_from_config( mas_config::CaptchaServiceKind::CloudflareTurnstile => { mas_data_model::CaptchaService::CloudflareTurnstile } + mas_config::CaptchaServiceKind::HCaptcha => mas_data_model::CaptchaService::HCaptcha, }; Ok(Some(mas_data_model::CaptchaConfig { diff --git a/crates/config/src/sections/captcha.rs b/crates/config/src/sections/captcha.rs index 4a732ff5..67a84b4a 100644 --- a/crates/config/src/sections/captcha.rs +++ b/crates/config/src/sections/captcha.rs @@ -27,6 +27,10 @@ pub enum CaptchaServiceKind { /// Use Cloudflare Turnstile #[serde(rename = "cloudflare_turnstile")] CloudflareTurnstile, + + /// Use ``HCaptcha`` + #[serde(rename = "hcaptcha")] + HCaptcha, } /// Configuration section to setup CAPTCHA protection on a few operations diff --git a/crates/data-model/src/site_config.rs b/crates/data-model/src/site_config.rs index 68ed5aea..207c4380 100644 --- a/crates/data-model/src/site_config.rs +++ b/crates/data-model/src/site_config.rs @@ -20,6 +20,7 @@ use url::Url; pub enum CaptchaService { RecaptchaV2, CloudflareTurnstile, + HCaptcha, } /// Captcha configuration diff --git a/crates/templates/src/context/captcha.rs b/crates/templates/src/context/captcha.rs index 95dec4f6..3e9e0924 100644 --- a/crates/templates/src/context/captcha.rs +++ b/crates/templates/src/context/captcha.rs @@ -33,6 +33,7 @@ impl Object for CaptchaConfig { mas_data_model::CaptchaService::CloudflareTurnstile => { "cloudflare_turnstile".into() } + mas_data_model::CaptchaService::HCaptcha => "hcaptcha".into(), }), Some("site_key") => Some(self.0.site_key.clone().into()), _ => None, diff --git a/docs/config.schema.json b/docs/config.schema.json index 73fbdf73..3bd7a6f6 100644 --- a/docs/config.schema.json +++ b/docs/config.schema.json @@ -1995,6 +1995,13 @@ "enum": [ "cloudflare_turnstile" ] + }, + { + "description": "Use ``HCaptcha``", + "type": "string", + "enum": [ + "hcaptcha" + ] } ] }, diff --git a/templates/components/captcha.html b/templates/components/captcha.html index d2ba474e..c0788d03 100644 --- a/templates/components/captcha.html +++ b/templates/components/captcha.html @@ -20,6 +20,8 @@ limitations under the License.
{%- elif captcha.service == "cloudflare_turnstile" -%}
+ {%- elif captcha.service == "hcaptcha" -%} +
{%- else -%} {{ throw(message="Invalid captcha service setup") }} {%- endif %} @@ -32,6 +34,8 @@ limitations under the License. {%- elif captcha.service == "cloudflare_turnstile" -%} + {%- elif captcha.service == "hcaptcha" -%} + {%- else -%} {{ throw(message="Invalid captcha service setup") }} {%- endif %}