Extension:ConfirmEdit/zh

此扩展已绑定在MediaWiki 1.18及以上版本 因此您不需要再次下载。 然而,您仍需要跟随提供的其他指示。
MediaWiki扩展手册
OOjs UI icon advanced.svg
ConfirmEdit
发布状态: 稳定版
MediaWiki Extension ConfirmEdit.png
实现 页面操作
描述 为页面保存增加验证码机制和其他用户命令
作者
  • Brion Vibber
  • Florian Schmidt
  • Sam Reed
最新版本 1.6.0 (Continuous updates)
兼容性方针 发行分支
MediaWiki 1.31+
PHP 5.5.9+
数据庫更新
许可协议 GNU通用公眾授權條款2.0或更新版本
下载
  • $wgCaptchaWhitelistIP
  • $wgCaptcha
  • $wgCaptchaClass
  • $wgCaptchaTriggers
  • $wgCaptchaTriggersOnNamespace
  • $wgCaptchaStorageClass
  • $wgCaptchaSessionExpiration
  • $wgCaptchaBadLoginExpiration
  • $wgCaptchaBadLoginPerUserExpiration
  • $ceAllowConfirmedEmail
  • $wgCaptchaBadLoginAttempts
  • $wgCaptchaBadLoginPerUserAttempts
  • $wgCaptchaWhitelist
  • $wgCaptchaRegexes
skipcaptcha
翻译ConfirmEdit扩展如果在translatewiki.net可用
检查使用和版本矩阵。
Vagrant角色 confirmedit
问题 开放的工作 · 报告错误

ConfirmEdit扩展让你使用各种不同的验证码技术,来阻止Spam机器 和其他自动化工具来编辑你的wiki,并阻止自动化登录来猜密码。(阻止暴力破用户解密码)

ConfirmEdit集成了几个技术或模块来生存验证码。

模块 描述 防Spam效果
简单验证码 用户需要解决一个简单的数学问题。
复杂验证码 用户需要识别一系列的以一种风格显示的字符。
数学验证码 用户需要解决一个以图片显示的数学问题。
问题验证码 用户需要回答由管理员设置的问题。 很高,直到崩溃
ReCaptcha 用户需要识别一系列视觉化或听觉化的字符,小部件由reCAPTCHA提供服务。
ReCaptcha NoCaptcha 向用户呈现基于JavaScript的机器人检查。如果检查失败,则会出现一个问题。

Some of these modules require additional setup work:

  • MathCaptcha requires both the presence of TeX and, for versions of MediaWiki after 1.17, the Math extension;
  • FancyCaptcha requires running a preliminary setup script in Python.

Caveats: CAPTCHAs reduce accessibility and cause inconvenience to human users. In addition, they are not 100% effective against bots, and they will not protect your wiki from spammers who are willing and able to use human labor to get through the CAPTCHAs. You may wish to use ConfirmEdit in conjunction with other anti-spam features. Regardless of the solution you use, if you have a publicly-editable wiki it's important to keep monitoring the "Recent changes" page.

安装Edit

如果使用不同于规定版本MediaWiki ,ConfirmEdit可能无法正常工作,when downloading via the "Extension distributor".
  • 如果使用Vagrant ,请通过vagrant roles enable confirmedit --provision安装
手动安装
  • 下载文件,并将其放置在您extensions/文件夹中的ConfirmEdit目录内。

CAPTCHA typesEdit

There are numerous different CAPTCHA types included with ConfirmEdit.

QuestyCaptchaEdit

This module presents a question and the user supplies the answer. You provide the questions in the configuration. This module has proven to offer a strong mechanism against spam bots; it also should have the advantage of a better accessibility, as textual questions can be read by text-to-speech software allowing visually impaired users (but not bots) to answer correctly.

Add the following to LocalSettings.php to enable this CAPTCHA, editing the Q&A:

// If your MediaWiki version is 1.25 or higher, use this line:
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ]);

// Else use these lines:
require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
require_once "$IP/extensions/ConfirmEdit/QuestyCaptcha.php";

// Add your questions in LocalSettings.php using this format:
$wgCaptchaQuestions = [
	'What is the capital of France?' => 'Paris',
	'What is the capital of Spain' => 'MADRID', // Answers are case insensitive
	'What is the name of this wiki?' => $wgSitename, // You can use variables
	'How many fingers does a hand have?' => [ 5, 'five' ], // A question may have many answers
];

You can also configure ConfirmEdit's triggers and other options. If the Captcha does not appear, add the following below the extension code. By setting any individual option to "true", the Captcha will be triggered when performing the named action. Otherwise you can write "false" to disable Captcha for this action.

$wgMainCacheType    = CACHE_ANYTHING;
$wgCaptchaTriggers['edit']          = true;
$wgCaptchaTriggers['create']        = true;
$wgCaptchaTriggers['createtalk']    = true;
$wgCaptchaTriggers['addurl']        = true;
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin']      = true;

It will randomly choose a question from those supplied. The minimum is one.

  • QuestyCaptcha is case-insensitive. If the answer is "Paris" and the user writes "paris", or if the answer is "paris" and the user writes "Paris", it will still work.
  • If the answer has a special character like "ó", you may write an answer with "ó" and another without, just in case. For example if the answer is "canción" you can use [ 'cancion', 'canción' ] in case the user writes "cancion".
  • The answer must be easy to guess for a human interested in your wiki, but not by an automatic program. Ideally, it should not be contained in the text of the question; you can try and edit the captcha help messages[1] and provide the solution to the captcha response there.
  • Just change the questions when/if they start proving ineffective; this may never happen if your wiki is not specifically targeted.
  • Don't ever reuse questions already used by you or others in the past: spambots are known to remember a question and its answer forever once they broke it.
  • You can even dynamically generate questy captchas in the configuration. DO NOT use an exact copy of the dynamic questions from the link -- they've been cracked by spammers. However other dynamic questions in the style of the questions presented are highly effective.

ReCaptcha (NoCaptcha)Edit

The ReCaptchaNoCaptcha module was introduced in the MediaWiki release 1.26; you can't use it in older versions of ConfirmEdit and MediaWiki.

The new generation of ReCaptcha, called NoCaptcha, was introduced by Google back in December 2014[2] and reduces the need for humans to solve a CAPTCHA. Based on a user-side JavaScript (which can't be controlled by the user the administrator), reCaptcha tries to identify the site user as a human by analyzing their browsing behavior on the page. The user then has to click an "I'm not a robot" checkbox and (in the best case) doesn't have to do anything further to prove they're a human. However, in some cases, the user still has to solve a CAPTCHA image.

Note: ReCaptcha will not work with the VisualEditor.

This module implements the new ReCaptcha NoCaptcha solution in ConfirmEdit. You still need a public and a secret key (which you can retrieve from the ReCaptcha admin panel – change v2, v3 not work) and install the plugin with:

wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/ReCaptchaNoCaptcha' ]);
$wgCaptchaClass = 'ReCaptchaNoCaptcha';
$wgReCaptchaSiteKey = 'your public/site key here';
$wgReCaptchaSecretKey = 'your private key here';

There is an additional configuration option for this module, $wgReCaptchaSendRemoteIP (default: false), which, if set to true, sends the IP address of the current user to a server from Google while verifying the CAPTCHA. You can improve the privacy for your users if you keep this set to "false". However, remember, that this module adds a client side JavaScript code, directly loaded from a server from Google, which already can collect the IP address of the user (combined with other data, too) and can not be limited by a configuration option. This will only work on standard MediaWiki editor.

SimpleCaptcha (calculation)Edit

  警告: This type is used by very few wikis outside WMF if any, probably because of scarce effectiveness.
 
a simple math question.

This is the default CAPTCHA. This module provides a simple addition or subtraction question for the user.

Add the following lines to LocalSettings.php in the root of your MediaWiki to enable this CAPTCHA:

$wgCaptchaClass = 'SimpleCaptcha';

Note that the display of a trivial maths problem as plaintext yields a captcha which can be trivially solved by automated means; as of 2012, sites using SimpleCaptcha are receiving significant amounts of spam and many automated registrations of spurious new accounts. Wikis currently using this as the default should therefore migrate to one of the other CAPTCHAs.

FancyCaptchaEdit

  警告: This type is used by very few wikis outside WMF if any, probably because of scarce effectiveness.

This module displays a stylized image of a set of characters. The Python Imaging Library must be installed in order to create the set of images initially, but isn't needed after that (can be installed with pip install pil in most environments).

  1. Add the following lines to LocalSettings.php in the root of your MediaWiki installation:
    MediaWiki version is 1.25 or newer:
    wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/FancyCaptcha' ]);
    $wgCaptchaClass = 'FancyCaptcha';
    MediaWiki version is older than 1.25:
    require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
    require_once "$IP/extensions/ConfirmEdit/FancyCaptcha.php";
    $wgCaptchaClass = 'FancyCaptcha';
  2. In LocalSettings.php, set the variable $wgCaptchaDirectory to the directory where you will store Captcha images. Below it set $wgCaptchaSecret to your passphrase.
  3. Create the images by running the following, where:
    • font is a path to some font, for instance AriBlk.TTF.
    • wordlist is a path to some word list, for instance /usr/share/dict/words. (Note: on Debian/Ubuntu, the 'wbritish' and 'wamerican' packages provide such lists. On Fedora, use the 'words' package).
    • key is the the exact passphrase you set $wgCaptchaSecret to. Use quotes if necessary.
    • output is the path to where the images should be stored (defined in $wgCaptchaDirectory).
    • count is how many images to generate.
    python /path/to/captcha.py --font=<font> --wordlist=<wordlist> --key=<key> --output=<output> --count=<count>
    • An example, assuming you're in the extensions/ConfirmEdit directory (font location from Ubuntu 6.06, probably different on other operating systems):
    python captcha.py --font=/usr/share/fonts/truetype/freefont/FreeSans.ttf --wordlist=/usr/share/dict/words --key=FOO --output=../../../captcha --count=100
    • If you are not satisfied with the results of the words you've generated you can simply remove the images and create a new set. Comic_Sans_MS_Bold.ttf seems to generate relatively legible words, and you could also edit the last line of captcha.py to increase the font size from the default of 40.
  4. Put the images you get into captcha directory in your installation
  5. Edit your wiki's LocalSettings.php : specify full path to your captcha directory in $wgCaptchaDirectory and secret key you've been using while generating captures in $wgCaptchaSecret
$wgCaptchaDirectory = "/.php-data/my-wiki.org/wiki/captcha";
$wgCaptchaDirectoryLevels = 0; // Set this to a value greater than zero to break the images into subdirectories
$wgCaptchaSecret = "FOO"; // same value you used in --key option in captcha.py

See also wikitech:Generating CAPTCHAs for how Wikimedia Foundation does it.

How to avoid common problems running Python
  1. Install the most recent version of Python Imaging Library (PIL).
  2. Make the installation of Python on a short folder name. Like C:\Python\
  3. Create a folder like C:\Ex and place files CAPTCHA.py / FONT.ttf / LIST.txt into the folder.
  4. To execute easily, run the following example as a batch file:
C:\python\python.exe C:\Ex\CAPTCHA.py --font C:\Ex\FONT.ttf --wordlist C:\Ex\LIST.txt --key=YOURPASSWORD --output C:\Ex\ --count=20

MathCaptchaEdit

  警告: This type is used by very few wikis outside WMF if any, probably because of scarce effectiveness.
This requires the Math extension to be installed. See also Extension:Math

This module generates an image using TeX to ask a basic math question.

Set the following to enable this CAPTCHA:

// Use this line ONLY if your MediaWiki version is 1.25 or newer:
wfLoadExtension( 'ConfirmEdit/MathCaptcha' );
// Use this line ONLY if your MediaWiki version is older than 1.25:
require_once "$IP/extensions/ConfirmEdit/MathCaptcha.php";
$wgCaptchaClass = 'MathCaptcha';

See the readme file in the math folder to install this captcha.

ConfigurationEdit

ConfirmEdit introduces a 'skipcaptcha' permission type to wgGroupPermissions . This lets you set certain groups to never see CAPTCHAs. All of the following can be added to localsettings.php.

Defaults from ConfirmEdit.php:

$wgGroupPermissions['*'            ]['skipcaptcha'] = false;
$wgGroupPermissions['user'         ]['skipcaptcha'] = false;
$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = false;
$wgGroupPermissions['bot'          ]['skipcaptcha'] = true; // registered bots
$wgGroupPermissions['sysop'        ]['skipcaptcha'] = true;

To skip captchas for users that confirmed their email, you need to set both:

$wgGroupPermissions['emailconfirmed']['skipcaptcha'] = true;
$ceAllowConfirmedEmail = true;

There are five "triggers" on which CAPTCHAs can be displayed:

  • 'edit' - triggered on every attempted page save
  • 'create' - triggered on page creation
  • 'addurl' - triggered on a page save that would add one or more URLs to the page
  • 'createaccount' - triggered on creation of a new account
  • 'badlogin' - triggered on the next login attempt after a failed one. Requires $wgMainCacheType to be set to something other than CACHE_NONE in your LocalSettings.php, if in doubt the following will always work. Note that badlogin does not trigger captchas on API login, but instead blocks them outright until $wgCaptchaBadLoginExpiration expires.
$wgMainCacheType = CACHE_ANYTHING;

The default values for these are:

$wgCaptchaTriggers['edit'] = false; 
$wgCaptchaTriggers['create'] = false; 
$wgCaptchaTriggers['addurl'] = true; 
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin'] = true;

The triggers edit, create and addurl can be configured per namespace using the $wgCaptchaTriggersOnNamespace setting. If there is no $wgCaptchaTriggersOnNamespace for the current namespace, the normal $wgCaptchaTriggers apply. So suppose that in addition to the above $wgCaptchaTriggers defaults we configure the following:

$wgCaptchaTriggersOnNamespace[NS_TALK]['addurl'] = false;
$wgCaptchaTriggersOnNamespace[NS_PROJECT]['edit'] = true;

Then the CAPTCHA will not trigger when adding URLs to a talk page, but on the other hand user will need to solve a CAPTCHA any time they try to edit a page in the project namespace, even if they aren't adding a link.

URL and IP whitelistsEdit

It is possible to define a whitelist of known "good" sites for which the CAPTCHA should not kick in, when the 'addurl' action is triggered.

Sysop users can do this by editing the system message page called [[MediaWiki:Captcha-addurl-whitelist]]. The expected format is a set of regex's one per line. Comments can be added with # prefix. You can see an example of this usage on OpenStreetMap.

This set of whitelist regexes can also be defined using the $wgCaptchaWhitelist config variable in LocalSettings.php, to keep the value(s) a secret.

Some other variables you can add to LocalSettings.php:

  • $wgCaptchaWhitelistIP - List of IP ranges to allow to skip the CAPTCHA (you can also use [[MediaWiki:Captcha-ip-whitelist]]; see below for details).
  • $ceAllowConfirmedEmail - Allow users who have confirmed their e-mail addresses to post URL links

These are described more thoroughly in the code comments

[[MediaWiki:Captcha-ip-whitelist]] can be used to change the whitelisted IP addresses and IP ranges on wiki. They should be separated by newlines. If any other character (apart from a valid IP address or range) is found on a line, it will be ignored but leading and trailing whitespace characters are allowed. For example, a line with only 127.0.0.1 is considered valid but #127.0.0.1 will be ignored.

Regular expressionsEdit

The global variable wgCaptchaRegexes accepts an array of regexes to be tested against the page text and will trigger the CAPTCHA in case of a match.

Wikimedia approachEdit

For example, Wikimedia Foundation wikis use FancyCaptcha with a custom set of images and the default configuration, modified by what follows.

$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;

This means only unregistered and newly registered users have to pass the CAPTCHA.

EmergencyCaptcha modeEdit

Additionally the shortcut named $wmgEmergencyCaptcha is designed for use in a limited number of emergency situations, for instance in case of massive vandalism or spam attacks: it changes the default trigger values (see above) into the following:

$wgCaptchaTriggers['edit'] = true; 
$wgCaptchaTriggers['create'] = true;

So all anonymous and new users have to solve a CAPTCHA also before being able to save an edit or create a new page, in addition to the normal situation.

Rate-LimitingEdit

With Gerrit change 182551, ConfirmEdit supports rate limiting for false CAPTCHA. For more information about $wgRateLimits and how to set it up, read 手册:$wgRateLimits , the action key is badcaptcha.

作者Edit

基础框架主要由Brion Vibber设计,此外他还编写了SimpleCaptcha和FancyCaptcha模块。MathCaptcha模块由Rob Church编写。QuestyCaptcha模块由 Benjamin Lees编写。reCAPTCHA模块由Mike Crawford和Ben Maurer编写。另外的维护工作由Yaron Koren完成。

注意Edit

  1. MediaWiki:Questycaptchahelp-text, MediaWiki:Questycaptcha-edit, MediaWiki:Questycaptcha-addurl, MediaWiki:Questycaptcha-create and MediaWiki:Questycaptcha-createaccount.
  2. Google Blog Are you a robot? Introducing “No CAPTCHA reCAPTCHA” (December 3, 2014)

参见Edit