mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 08:13:53 +00:00
fbf6c1c7ea
This is a rudimentary implementation of Cloudflare's Turnstile captcha alternative. Since it is fairly similar to ReCaptchaNoCaptcha, there is some duplicate code used here. I opted not to use the migration path that CF has for reCAPTCHA v2 and build this as a separate implementation. After T324925, it should be easy to refactor this code. Users should set $wgTurnstileSiteKey and $wgTurnstileSecretKey as appropriate, based on details from the Cloudflare dashboard. Bug: T319068 Change-Id: I0d5a74655619975f0bf61b5b672159afe5f4fb00
28 lines
737 B
PHP
28 lines
737 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\Turnstile;
|
|
|
|
use Config;
|
|
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
|
|
|
class Hooks implements ResourceLoaderGetConfigVarsHook {
|
|
/**
|
|
* Adds extra variables to the global config
|
|
*
|
|
* @param array &$vars Global variables object
|
|
* @param string $skin
|
|
* @param Config $config
|
|
*/
|
|
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
|
|
global $wgTurnstileSiteKey;
|
|
global $wgCaptchaClass;
|
|
|
|
if ( $wgCaptchaClass === Turnstile::class ) {
|
|
$vars['wgConfirmEditConfig'] = [
|
|
'turnstileSiteKey' => $wgTurnstileSiteKey,
|
|
'turnstileScriptURL' => 'https://challenges.cloudflare.com/turnstile/v0/api.js'
|
|
];
|
|
}
|
|
}
|
|
}
|