Extension:ConfirmEdit
Language: | English • Deutsch |
---|
ConfirmEdit Release status: stable |
|||
---|---|---|---|
Implementation | Page action | ||
Description | Adds CAPTCHAs for page saves and other user actions | ||
Author(s) | Brion Vibber and others | ||
Last version | 1.1 (2011-07-12) | ||
MediaWiki | 1.11+ | ||
License | GPL | ||
Download | |||
Example | One screenshot of ConfirmEdit running on Wikimanga.net | ||
|
|||
|
|||
|
|||
Check usage (experimental) |
The ConfirmEdit extension lets you use various different CAPTCHA techniques, to try to prevent spambots and other automated tools from editing your wiki, as well as to foil automated login attempts that try to guess passwords.
ConfirmEdit ships with several techniques/modules to generate captcha.
Module | Description |
---|---|
SimpleCaptcha | users have to solve a simple math problem |
FancyCaptcha | users have to identify a series of characters, displayed in a stylized way |
MathCaptcha | users have to solve a math problem that's displayed as an image |
QuestyCaptcha | users have to answer a question, out of a series of questions defined by the administrator(s) |
Asirra | users have to identify the cats in a set of photos of cats and dogs, from a widget provided by the Asirra service |
ReCaptcha | users have to identify a series of characters, either visually or audially, from a widget provided by the reCAPTCHA service. |
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;
- and reCAPTCHA requires obtaining API keys.
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 in any way from human spammers. 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.
Contents |
[edit] Installation
The ConfirmEdit extension requires MediaWiki 1.11.0 or higher and PHP5 (but revisions on SVN before 21970 are PHP4-compatible).
- Download the latest version and save it to your computer
- Create a folder in the extensions folder named ConfirmEdit
- Move the files to the extensions/ConfirmEdit/ folder
- Edit LocalSettings.php in the root of your MediaWiki installation, and add the following line near the bottom:
require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" );
Note: ConfirmEdit may not work if used with a MediaWiki version different from the one specified when downloading via the "Extension distributor".
[edit] CAPTCHA types
There are numerous different CAPTCHA types included with ConfirmEdit.
[edit] SimpleCaptcha (calculation)
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 default setting should therefore migrate to VisualMathCaptcha or one of the other CAPTCHAs.
[edit] FancyCaptcha
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.
- Add the following lines to LocalSettings.php in the root of your MediaWiki installation:
require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" );
require_once( "$IP/extensions/ConfirmEdit/FancyCaptcha.php" );
$wgCaptchaClass = 'FancyCaptcha';
- In LocalSettings.php, set the variable $wgCaptchaDirectory to the directory where you will store Captcha images. Below it set $wgCaptchaSecret to your passphrase.
- 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.
- Put the images you get into captcha directory in your installation
- 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
[edit] How to avoid common problems running Python
- Install the most recent version of Python Imaging Library (PIL).
- Make the installation of Python on a short folder name. Like C:\Python\
- Create a folder like C:\Ex and place files CAPTCHA.py / FONT.ttf / LIST.txt into the folder.
- 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
[edit] MathCaptcha
- This requires the Math extension to be installed.
Until MediaWiki 1.18 this was part of MediaWiki, later versions need to it manually. See also Extension:Math
This module generates an image using TeX to ask a basic math question.
Set the following to enable this CAPTCHA:
require_once("$IP/extensions/ConfirmEdit/MathCaptcha.php"); $wgCaptchaClass = 'MathCaptcha';
See the readme file in the math folder to install this captcha.
[edit] QuestyCaptcha
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.
Set the following to enable this CAPTCHA:
require_once("$IP/extensions/ConfirmEdit/QuestyCaptcha.php"); $wgCaptchaClass = 'QuestyCaptcha'; $wgCaptchaQuestions[] = array( 'question' => 'A question?', 'answer' => 'An answer!' ); $wgCaptchaQuestions[] = array( 'question' => 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?', 'answer' => 'as much wood as...' ); $wgCaptchaQuestions[] = array( 'question' => "What is this wiki's name?", 'answer' => "$wgSitename" ); $wgCaptchaQuestions[] = array( 'question' => 'Please write the magic secret, "passion", here:', 'answer' => 'passion' ); $wgCaptchaQuestions[] = array( 'question' => 'Type the code word, 567, here:', 'answer' => '567' ); $wgCaptchaQuestions[] = array( 'question' => 'Which animal is displayed here? <img src="http://www.example.com/path/to/filename_not_including_dog.jpg" alt="" title="" />', 'answer' => 'dog' );
It will randomly choose a question from those supplied. The minimum is one.
[edit] Asirra
This module displays the Asirra (Animal Species Image Recognition for Restricting Access) widget, created by Microsoft Research. The widget shows 12 random images from the Petfinder pet-adoption website, all of which are of either a cat or a dog, and asks the user to select only the images of cats.
Image recognition is an inherently more difficult task for computers than character recognition; and the use of Petfinder's massive, and ever-changing, database of millions of images makes it seemingly impossible for spammers to attempt to beat the system via some shortcut. It should be noted, though, that some research exists showing that image-recognition software can beat Asirra at least 10% of the time. Still, Asirra may possibly be the most secure of the modules within ConfirmEdit.
Note: in order to use Asirra, you will need to download the latest/trunk version of ConfirmEdit.
Add the following to LocalSettings.php to enable this CAPTCHA:
require_once("$IP/extensions/ConfirmEdit/Asirra.php"); $wgCaptchaClass = 'Asirra';
In addition, you can add any of the following configuration parameters:
- $wgAsirraEnlargedPosition: Can be one of top, bottom, left, right. Defaults to bottom.
- $wgAsirraCellsPerRow: Number of images per row. Defaults to 6.
- $wgAsirraScriptPath: If your extensions directory is outside the document root, or not accessible for any reason, you can set an alternative path to this module's JavaScript scripts here.
[edit] ReCaptcha
This module uses the "reCAPTCHA" widget/service. In addition to providing a CAPTCHA, it performs a valuable service because it helps to digitize old books (read more here.)
To use this module, first go here and obtain a public and private key for your wiki.
Add the following to LocalSettings.php, below the inclusion of ConfirmEdit:
require_once("$IP/extensions/ConfirmEdit/ReCaptcha.php"); $wgCaptchaClass = 'ReCaptcha'; $wgReCaptchaPublicKey = 'your public key here'; $wgReCaptchaPrivateKey = 'your private key here';
- Recaptcha is only in the latest 1.18 version of ConfirmEdit. Earlier version do not have the ReCaptcha php files.
- Unfortunately, as of 2011, some spammers appear to have figured out a way to bypass it, either through character recognition or by using humans. For that reason, it is not necessarily recommended.
- Part of the weakness of the ReCaptcha module is that ConfirmEdit doesn't include any penalty mechanism, so spam bots can simply keep trying to bypass the CAPTCHA until they get through. This is an issue that is strongly worth addressing in some way.
- Regardless of its strengths or weaknesses, ReCaptcha can't be implemented on Wikimedia wikis because it produces a third party dependency.
[edit] Outside extensions
[edit] VisualMathCaptcha
The extension VisualMathCaptcha can also be used, in conjunction with ConfirmEdit. See that extension's documentation for how to install and configure it.
[edit] Configuration
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 both set:
$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.
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.
A common alternate setting is to have a CAPTCHA only for unregistered users, on every edit. This can be accomplished by:
$wgGroupPermissions['user']['skipcaptcha'] = true; $wgCaptchaTriggers['edit'] = true;
[edit] URL and IP whitelists
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 here, 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
- $ceAllowConfirmedEmail - Allow users who have confirmed their e-mail addresses to post URL links
These are described more thoroughly in the code comments
[edit] Test plan
[edit] Authors
The basic framework was designed largely by Brion Vibber, who also wrote the SimpleCaptcha and FancyCaptcha modules. The Asirra module was written by Bachsau. The MathCaptcha module was written by Rob Church. The QuestyCaptcha module was written by Benjamin Lees. The reCAPTCHA module was written by Mike Crawford and Ben Maurer. Additional maintenance work was done by Yaron Koren.
[edit] See also
![]() |
This extension is being used on one or more of Wikimedia's wikis. This means that the extension is stable and works well enough to be used by such high traffic websites. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |
- Stable extensions
- Page action extensions
- Extensions in Wikimedia version control
- Extensions which add rights
- EditFilterMerged extensions
- EditFilter extensions
- UserCreateForm extensions
- AbortNewAccount extensions
- LoginAuthenticateAudit extensions
- UserLoginForm extensions
- AbortLogin extensions
- APIEditBeforeSave extensions
- All extensions
- 2012 Q1 Extension Page Review Drive - completed
- Extensions used on Wikimedia
- Edit extensions
- Spam management extensions