From ff805d8ae16fbf2bc165dc3c05e37c8472ede7fc Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 8 Jul 2025 19:27:51 +0100 Subject: [PATCH 1/4] feat(recaptcha): Fix linting issues after the linter fix lied to me --- src/service/uiaa/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/uiaa/mod.rs b/src/service/uiaa/mod.rs index de08f227..7735c87f 100644 --- a/src/service/uiaa/mod.rs +++ b/src/service/uiaa/mod.rs @@ -192,7 +192,7 @@ pub async fn try_auth( ) .await { - | Ok() => { + | Ok(()) => { uiaainfo.completed.push(AuthType::ReCaptcha); }, | Err(e) => { From 14774fa15358911cd88e1e848ebfbf690f5876b4 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 8 Jul 2025 19:32:23 +0100 Subject: [PATCH 2/4] feat(recaptcha): Don't allow pubkey without associated privkey --- src/core/config/check.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/config/check.rs b/src/core/config/check.rs index 8a3d1f77..6710a91a 100644 --- a/src/core/config/check.rs +++ b/src/core/config/check.rs @@ -180,11 +180,18 @@ pub fn check(config: &Config) -> Result { } } + if config.recaptcha_site_key.is_some() && config.recaptcha_private_site_key.is_none() { + return Err!(Config( + "recaptcha_private_site_key", + "reCAPTCHA private site key is required when reCAPTCHA site key is set." + )); + } + if config.allow_registration && !config.yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse && config.registration_token.is_none() && config.registration_token_file.is_none() - && !(config.recaptcha_site_key.is_some() && config.recaptcha_private_site_key.is_some()) + && config.recaptcha_site_key.is_none() { return Err!(Config( "registration_token", From c362499ceffbc646633e310549085fdb3195ad6e Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 8 Jul 2025 19:34:47 +0100 Subject: [PATCH 3/4] docs(recaptcha): Clarify registration when token & captcha are configured --- src/core/config/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 9df01d46..d93acd9b 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -557,8 +557,9 @@ pub struct Config { pub registration_token_file: Option, /// The public site key for reCaptcha. If this is provided, reCaptcha - /// becomes required during registration, **even if token registration is - /// enabled**. + /// becomes required during registration. If both captcha *and* + /// registration token are enabled, both will be required during + /// registration. /// /// IMPORTANT: "Verify the origin of reCAPTCHA solutions" **MUST** BE /// DISABLED IF YOU WANT THE CAPTCHA TO WORK IN 3RD PARTY CLIENTS, OR From b71186d9588a2b4998899cc2df99f0ab7e764bea Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 8 Jul 2025 19:47:42 +0100 Subject: [PATCH 4/4] chore(recaptcha): Update example config file Unsure how this managed to get past the `git commit -S -a` but sure --- conduwuit-example.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index c6301af5..bdc2f570 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -442,8 +442,9 @@ #registration_token_file = # The public site key for reCaptcha. If this is provided, reCaptcha -# becomes required during registration, **even if token registration is -# enabled**. +# becomes required during registration. If both captcha *and* +# registration token are enabled, both will be required during +# registration. # # IMPORTANT: "Verify the origin of reCAPTCHA solutions" **MUST** BE # DISABLED IF YOU WANT THE CAPTCHA TO WORK IN 3RD PARTY CLIENTS, OR