Extension:ConfirmEdit

This page is a translated version of the page Extension:ConfirmEdit and the translation is 36% complete.
この拡張機能は MediaWiki 1.18 以降に同梱されています。 そのため再度ダウンロードする必要はありません。 しかし、提供されているその他の手順に従う必要はあります。
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced-invert.svg
ConfirmEdit
リリースの状態: 安定
MediaWiki Extension ConfirmEdit.png
実装 ページの操作
説明 ページ保存やその他の利用者操作を行うときに CAPTCHA (キャプチャ) を追加する。
作者
  • Brion Vibber
  • Florian Schmidt
  • Sam Reed
最新バージョン 1.6.0 (継続的な更新)
互換性ポリシー MediaWikiとともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki 1.31+
PHP 5.5.9+
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgAllowConfirmedEmail
  • $wgCaptchaBadLoginExpiration
  • $wgCaptchaTriggersOnNamespace
  • $wgCaptchaStorageClass
  • $wgCaptchaSessionExpiration
  • $wgCaptchaRegexes
  • $wgCaptchaWhitelistIP
  • $wgCaptchaWhitelist
  • $wgCaptchaTriggers
  • $wgCaptchaBadLoginPerUserAttempts
  • $wgCaptchaBadLoginPerUserExpiration
  • $wgCaptcha
  • $wgCaptchaBadLoginAttempts
  • skipcaptcha
translatewiki.net で翻訳を利用できる場合は、ConfirmEdit 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

Vagrant role confirmedit
問題点 未解決のタスク · バグを報告

ConfirmEdit拡張機能を使うと、さまざまなCAPTCHA技術を使って、スパムボットなどの自動編集ツールによるウィキの編集を防いだり、パスワードを推測しようとする自動ログインを無効化したりすることができます。

ConfirmEditはキャプチャを生成するためいくつかの技術やモジュールが同梱されてます。

モジュール 説明 スパム抑制における有効性
SimpleCaptcha 利用者は簡単な数学の問題を解く必要がある。
FancyCaptcha 利用者は表示された、変形が加わった一連の文字の内容を答える必要がある。
MathCaptcha 利用者は画像として表示された数学の問題を解く必要がある。
QuestyCaptcha 利用者は管理者が設けたいくつかの質問の中から一つに答える必要がある。 解読されるまでは非常に高い
ReCaptcha NoCaptcha 利用者には JavaScript に基づいた人によるアクセスであることのチェックが表示される。チェックに失敗するとパズルが表示される。 中から低
hCaptcha ReCaptcha(リキャプチャ)と似ていますが、different approach to accessibility-friendlyキャプチャーがあるため、ReCaptchaよりも効果的であることは間違いないでしょう。 不明

これらのモジュールの中には、追加の設定作業が必要なものがあります。

  • MathCaptcha requires both the presence of TeX and, for versions of MediaWiki after 1.17, the Math extension;
  • FancyCaptchaは、Pythonで予備設定スクリプトを実行する必要があります。

欠点

CAPTCHA は、利便性を低下させ、人間の利用者にとっては不便です。

また、ボットに対して100%有効というわけではなく、CAPTCHAを突破するために人手を使うことを厭わないスパマーからWikiを守ることはできません。 ConfirmEditは、他のアンチスパム機能と組み合わせて使用することも可能です。 どのようなソリューションを使うにしても、公開可能なWikiを持っているならば、「最近の更新」を常に監視することが重要です。

インストール

"Extension distributor"でダウンロードする際に指定したMediaWikiのバージョンと異なる場合、ConfirmEditが動作しないことがあります。
  • Vagrant を使用している場合は、vagrant roles enable confirmedit --provisionでインストールしてください。
手動インストール

CAPTCHAの種類

ConfirmEditに含まれるCAPTCHAの種類は多数あります。

QuestyCaptcha

このモジュールは、質問を提示し、利用者がその答えを提供するものです。 設定にある質問を提示します。 このモジュールは、スパムボットに対して強力なメカニズムを提供することが証明されています。また、テキスト形式の問題は音声合成ソフトで読み上げることができるため、視覚障害者(ボットではなく)が正しく回答できるという、より良いアクセシビリティの利点もあります。 このCAPTCHAを有効にするために、Q&Aを編集しているLocalSettings.phpに以下を追加してください。

// あなたのMediaWikiのバージョンが1.25以上ならこの欄を使用してください。
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ]);

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

// このフォーマットでLocalSettings.phpに質問を追加してください。
$wgCaptchaQuestions = [
	'What is the capital of France?' => 'Paris',
	'What is the capital of Spain' => 'MADRID', // * 大小文字は区別されません。
	'What is the name of this wiki?' => $wgSitename, // 変数を使用できます。
	'How many fingers does a hand have?' => [ 5, 'five' ], // 質問は多くの答えを持つようになるかもしれません
];

また、ConfirmEditのトリガーやその他のオプションを設定することができます。 もし、Captchaが表示されないなら以下のコードを書き加えてください。 個々のオプションに true を設定することで、指定された操作を実行する際に Captcha がトリガーされます。 そうでなければ、この操作の Captcha を無効にするために false を書くことができます。

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

入力された問題の中から、ランダムに出題されます。

最低でも1つは必要です。

  • QuestyCaptchaは大文字と小文字を区別しません。 答えが「Paris」で利用者が「paris」と書いても、答えが「paris」で利用者が「Paris」と書いても、動作は同じです。
  • 答えに「ó」のような特殊文字がある場合、念のため「ó」入りの答えとそうでない答えを書いてもかまいません。 例えば、答えが「canción」であり、利用者が「cancion」を入力する場合は、[ 'cancion', 'canción' ] を使用できます。
  • あなたのウィキでインストールしても人間が推測することは簡単です。しかし、自動のプログラムでは難しいです。 理想では、質問のテキストに含まれるべきではありません。キャプチャヘルプメッセージを編集して、そこにキャプチャレスポンスの解決策を提供してみてください。[1]
  • 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)

The ReCaptchaNoCaptcha module was introduced in the MediaWiki release 1.26; you can't use it in older versions of ConfirmEdit and MediaWiki.
  警告: ReCaptcha has been cracked by most spambots targeting wikis, mainly due to its accessible captcha alternative.

The new generation of ReCaptcha, called NoCaptcha, was introduced by Google back in December 2014 and reduces the need for humans to solve a CAPTCHA.[2]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.

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.

Recaptcha V3

Currently there is no official way to implement version 3 of google recaptcha but if you want to test it on your wiki you can choose to try the following patches

SimpleCaptcha (calculation)

  警告: 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.

FancyCaptcha

  警告: 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.

Pillow must be installed in order to create the set of images initially, but isn't needed after that (can be installed with pip install Pillow 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 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; // <span lang="en" dir="ltr" class="mw-content-ltr">Set this to a value greater than zero to break the images into subdirectories</span>
$wgCaptchaSecret = "FOO"; // <span lang="en" dir="ltr" class="mw-content-ltr">Same value you used in --key option in captcha.py</span>

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

How to avoid common problems running Python on Windows
  1. Install the most recent version of Pillow.
  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

MathCaptcha

  警告: 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.

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.

hCaptcha

MediaWiki バージョン:
1.35
Currently, only the master version or the version 1.35 of ConfirmEdit officially support hCaptcha. An unofficial backport is available for MediaWiki 1.31-1.34, but it is not official. Use it at your own risk.

The configuration is similar to ReCaptcha:

wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/hCaptcha' ]);
$wgHCaptchaSiteKey = 'your public/site key here';
$wgHCaptchaSecretKey = 'your private key here';

$wgHCaptchaSendRemoteIP is also available.

設定

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 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 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.

正規表現

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 approach

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 mode

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.

速度制限

Gerrit change 182551と共にConfirmEditはfalse CAPTCHAのレートリミットをサポートしています。

$wgRateLimits の詳細情報とセットアップ方法は Manual:$wgRateLimits を参照してください。操作キーは badcaptcha です。

作者

基本的なフレームワークは、主にBrion Vibberが設計し、SimpleCaptchaとFancyCaptchaのモジュールも書きました。

MathCaptchaはRob Churchによって書かれました。

QuestyCaptchaはBenjamin Leesによって書かれました。

追加整備はYaron Korenにより行われました。

脚注

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

関連項目