From 133c08814cb723bffa78c8dd1db61982faf4d3ae Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Tue, 2 Aug 2022 20:49:36 +0300 Subject: [PATCH] wiki: switch to using hcaptcha Fixes: https://github.com/openstreetmap/operations/issues/454 --- cookbooks/foundation/recipes/board.rb | 2 -- cookbooks/foundation/recipes/dwg.rb | 2 -- cookbooks/foundation/recipes/mwg.rb | 2 -- cookbooks/foundation/recipes/wiki.rb | 2 -- cookbooks/mediawiki/resources/site.rb | 8 ++++---- .../default/mw-ext-ConfirmEdit.inc.php.erb | 16 ++++++++-------- cookbooks/wiki/recipes/default.rb | 4 ++-- test/data_bags/wiki/passwords.json | 2 +- 8 files changed, 15 insertions(+), 23 deletions(-) diff --git a/cookbooks/foundation/recipes/board.rb b/cookbooks/foundation/recipes/board.rb index ac39f67f5..82b2eb8ff 100644 --- a/cookbooks/foundation/recipes/board.rb +++ b/cookbooks/foundation/recipes/board.rb @@ -35,8 +35,6 @@ mediawiki_site "board.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["board"]["recaptcha"] version "1.37" end diff --git a/cookbooks/foundation/recipes/dwg.rb b/cookbooks/foundation/recipes/dwg.rb index ae0f1d37a..f939fb420 100644 --- a/cookbooks/foundation/recipes/dwg.rb +++ b/cookbooks/foundation/recipes/dwg.rb @@ -35,8 +35,6 @@ mediawiki_site "dwg.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["dwg"]["recaptcha"] version "1.37" end diff --git a/cookbooks/foundation/recipes/mwg.rb b/cookbooks/foundation/recipes/mwg.rb index 4775934a9..dd0bdab52 100644 --- a/cookbooks/foundation/recipes/mwg.rb +++ b/cookbooks/foundation/recipes/mwg.rb @@ -35,8 +35,6 @@ mediawiki_site "mwg.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["mwg"]["recaptcha"] version "1.37" end diff --git a/cookbooks/foundation/recipes/wiki.rb b/cookbooks/foundation/recipes/wiki.rb index b6470e158..199389d0e 100644 --- a/cookbooks/foundation/recipes/wiki.rb +++ b/cookbooks/foundation/recipes/wiki.rb @@ -41,8 +41,6 @@ mediawiki_site "wiki.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Wiki" private_accounts true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["wiki"]["recaptcha"] extra_file_extensions ["mp3"] version "1.37" end diff --git a/cookbooks/mediawiki/resources/site.rb b/cookbooks/mediawiki/resources/site.rb index 82ae15c28..6763797dd 100644 --- a/cookbooks/mediawiki/resources/site.rb +++ b/cookbooks/mediawiki/resources/site.rb @@ -42,8 +42,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 :recaptcha_public_key, :kind_of => String -property :recaptcha_private_key, :kind_of => String +property :hcaptcha_public_key, :kind_of => String, :default => "" +property :hcaptcha_private_key, :kind_of => String, :default => "" property :extra_file_extensions, :kind_of => [String, Array], :default => [] property :fpm_max_children, :kind_of => Integer, :default => 5 property :fpm_start_servers, :kind_of => Integer, :default => 2 @@ -297,8 +297,8 @@ action :create do mediawiki_extension "ConfirmEdit" do site new_resource.site template "mw-ext-ConfirmEdit.inc.php.erb" - variables :public_key => new_resource.recaptcha_public_key, - :private_key => new_resource.recaptcha_private_key + variables :public_key => new_resource.hcaptcha_public_key, + :private_key => new_resource.hcaptcha_private_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 50e1d4801..2e0af37ba 100644 --- a/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb +++ b/cookbooks/mediawiki/templates/default/mw-ext-ConfirmEdit.inc.php.erb @@ -1,12 +1,12 @@ '; -$wgReCaptchaSecretKey = '<%= @private_key %>'; - -$wgCaptchaTriggers['addurl'] = true; -$wgCaptchaTriggers['create'] = true; +wfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/hCaptcha' ) ); +$wgHCaptchaSendRemoteIP = true; +$wgHCaptchaSiteKey = '<%= @public_key %>'; +$wgHCaptchaSecretKey = '<%= @private_key %>'; $wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true; +$wgGroupPermissions['bot' ]['skipcaptcha'] = true; +$wgGroupPermissions['sysop' ]['skipcaptcha'] = true; + +$wgRateLimits['badcaptcha']['newbie'] = [ 100, 86400 ]; diff --git a/cookbooks/wiki/recipes/default.rb b/cookbooks/wiki/recipes/default.rb index 72af19cb8..ef0d16b8b 100644 --- a/cookbooks/wiki/recipes/default.rb +++ b/cookbooks/wiki/recipes/default.rb @@ -53,8 +53,8 @@ mediawiki_site "wiki.openstreetmap.org" do metanamespace "Wiki" - recaptcha_public_key "6LdFIQATAAAAAMwtHeI8KDgPqvRbXeNYSq1gujKz" - recaptcha_private_key passwords["recaptcha"] + hcaptcha_public_key "b67a410b-955e-4049-b432-f9c00e0202c0" + hcaptcha_private_key passwords["hcaptcha"] # site_notice "MAINTENANCE: WIKI READ-ONLY UNTIL Monday 16 May 2016 - 11:00am UTC/GMT." # site_readonly "MAINTENANCE: WIKI READ-ONLY UNTIL Monday 16 May 2016 - 11:00am UTC/GMT." diff --git a/test/data_bags/wiki/passwords.json b/test/data_bags/wiki/passwords.json index 109e87137..961e60f96 100644 --- a/test/data_bags/wiki/passwords.json +++ b/test/data_bags/wiki/passwords.json @@ -1,6 +1,6 @@ { "database": "database_password", "admin": "admin_password", - "recaptcha": "precaptcha_token", + "hcaptcha": "precaptcha_token", "thunderforest": "thunderforest_token" } -- 2.39.5