From 5c2020cfdb009a34333904fcc0773462e64a4ebc Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Thu, 5 Feb 2026 21:16:36 +0000 Subject: [PATCH] wiki: Switch Captcha to Turnstile --- cookbooks/mediawiki/resources/site.rb | 8 ++++---- .../templates/default/mw-ext-ConfirmEdit.inc.php.erb | 10 ++++++---- cookbooks/wiki/recipes/default.rb | 4 ++-- test/data_bags/wiki/passwords.json | 5 +++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index 760e152df..1efa54d5c 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -41,8 +41,8 @@ property :admin_user, :kind_of => String, :default => "Admin" property :admin_password, :kind_of => String, :required => [:create] property :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false property :private_site, :kind_of => [TrueClass, FalseClass], :default => false -property :hcaptcha_public_key, :kind_of => String, :default => "" -property :hcaptcha_private_key, :kind_of => String, :default => "" +property :turnstile_site_key, :kind_of => String, :default => "" +property :turnstile_secret_key, :kind_of => String, :default => "" property :extra_file_extensions, :kind_of => [String, Array], :default => [] property :namespaces, :kind_of => Hash, :default => {} property :force_ui_messages, :kind_of => Array, :default => [] @@ -243,8 +243,8 @@ action :create do mediawiki_extension "ConfirmEdit" do site new_resource.site template "mw-ext-ConfirmEdit.inc.php.erb" - variables :public_key => new_resource.hcaptcha_public_key, - :private_key => new_resource.hcaptcha_private_key + variables :turnstile_site_key => new_resource.turnstile_site_key, + :turnstile_secret_key => new_resource.turnstile_secret_key update_site false end end diff --git a/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb b/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb index 2e0af37ba..4dd46cf4c 100644 --- a/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb +++ b/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb @@ -1,9 +1,11 @@ '; -$wgHCaptchaSecretKey = '<%= @private_key %>'; +wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/Turnstile' ]); +$wgCaptchaClass = MediaWiki\Extension\ConfirmEdit\Turnstile\Turnstile::class; + +$wgTurnstileSiteKey= '<%= @turnstile_site_key %>'; +$wgTurnstileSecretKey= '<%= @turnstile_secret_key %>'; +$wgTurnstileSendRemoteIP = true; $wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true; $wgGroupPermissions['bot' ]['skipcaptcha'] = true; diff --git a/cookbooks/wiki/recipes/default.rb b/cookbooks/wiki/recipes/default.rb index c80c439b0..eb19ce690 100644 --- a/cookbooks/wiki/recipes/default.rb +++ b/cookbooks/wiki/recipes/default.rb @@ -54,8 +54,8 @@ mediawiki_site site_name do metanamespace "Wiki" - hcaptcha_public_key "b67a410b-955e-4049-b432-f9c00e0202c0" - hcaptcha_private_key passwords["hcaptcha"] + turnstile_site_key passwords["turnstile_site_key"] + turnstile_secret_key passwords["turnstile_secret_key"] namespaces "DE" => { :id => 200, :talk_id => 201 }, "FR" => { :id => 202, :talk_id => 203 }, diff --git a/test/data_bags/wiki/passwords.json b/test/data_bags/wiki/passwords.json index 961e60f96..ff95f6c31 100644 --- a/test/data_bags/wiki/passwords.json +++ b/test/data_bags/wiki/passwords.json @@ -1,6 +1,7 @@ { "database": "database_password", "admin": "admin_password", - "hcaptcha": "precaptcha_token", - "thunderforest": "thunderforest_token" + "thunderforest": "thunderforest_token", + "turnstile_site_key": "turnstile_site_key_value", + "turnstile_secret_key": "turnstile_secret_key_value" } -- 2.39.5