擴充功能:ConfirmEdit
![]() 發行狀態: 穩定版 |
|
---|---|
![]() |
|
實現 | 頁面操作 |
描述 | 為頁面保存和其他用戶操作添加驗證碼 |
作者 |
|
最新版本 | 1.6.0 (持續更新) |
相容性政策 | 快照跟隨MediaWiki發佈。 master分支不向後相容。 |
MediaWiki | >= 1.43 |
授權條款 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
|
|
季度下載量 | 169 (Ranked 34th) |
正在使用的公開wiki數 | 957 (Ranked 278th) |
前往translatewiki.net翻譯ConfirmEdit擴充功能 | |
Vagrant角色 | confirmedit |
問題 | 開啟的任務 · 回報錯誤 |
通過ConfirmEdit擴充功能,您可以使用各種不同的驗證碼技術,嘗試去阻止那些垃圾訊息機械人和其他自動化工具去編輯您的wiki,以及去挫敗那些試圖猜測密碼的自動登入。
ConfirmEdit配備了多種生成驗證碼的技術/模組。
模組 | 描述 | 阻止垃圾郵件的效果 |
---|---|---|
SimpleCaptcha |
用戶必須解決一道簡單的數學題。 | 低 |
FancyCaptcha |
用戶必須辨識以風格化方式顯示的一系列字元。 | 低 |
MathCaptcha |
用戶必須解決一個以圖像顯示的數學問題。 | 低 |
QuestyCaptcha |
用戶必須從管理員定義的一系列問題中回答一個問題。 | 非常高,直至破裂 |
ReCaptcha NoCaptcha
|
用戶將看到一個基於JavaScript的人性檢查。如果檢查失敗,就會出現一個謎題。 | 中-低 |
hCaptcha
|
與reCAPTCHA類似,但可以說比reCAPTCHA更有效,因為它採用了不同的無障礙驗證碼方法。 | 未知 |
Turnstile
|
Cloudflare Turnstile. Human actionless (or just clicking the box) bot detector. | Unknown |
其中一些模組需要額外的設置工作:
- MathCaptcha需要使用TeX擴充功能,對於MediaWiki版本在1.17之後的,還需要再加上Math 擴充功能;
- FancyCaptcha需要在Python中執行一個初步設置指令碼。
缺點
驗證碼會降低可訪問性並給真人用戶帶來不便。
They also 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.
安裝
- 下載檔案,並將解壓後的
ConfirmEdit
資料夾移動到extensions/
目錄中。
開發者和代碼貢獻人員應從Git安裝擴充功能,輸入:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit - 將下列程式碼放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'ConfirmEdit' );
- Enable the CAPTCHA type which should be used
- Configure as needed
完成 – 在您的wiki上導覽至Special:Version,以驗證已成功安裝擴充功能。
使用Vagrant安裝:
- 如果使用Vagrant ,請透過
vagrant roles enable confirmedit --provision
安裝
驗證碼類型
There are numerous different CAPTCHA types included with ConfirmEdit.
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 spambots; it should also have the advantage of 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:
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ]);
// 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
];
It will randomly choose a question from those supplied.
最小值為1。
- 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 with "o" (where "o" replaces "ó"), 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 and provide the solution to the captcha response there.[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.
- There is a separate extension to ConfirmEdit called QuestyCaptchaEditor which provides an on-wiki special page for managing QuestyCaptcha question+answer(s) pairings. You may wish to consider installing it if it's desirable to reduce sysadmin intervention when it comes to managing the CAPTCHA questions and their answers.
ReCaptcha (NoCaptcha)
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.
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' ]);
$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.
SimpleCaptcha (calculation)
![](http://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/SimleCaptcha_screenshot.png/350px-SimleCaptcha_screenshot.png)
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';
請注意,像這樣把簡單數學問題顯示成明文將可以通過自動化程式輕鬆解決;截至2012年,使用SimpleCaptcha的網站正在收到大量垃圾郵件和許多虛假帳戶的自動註冊。因此,當前使用此作為預設設置的Wiki應使用其他驗證碼。 Wikis currently using this as the default should therefore migrate to one of the other CAPTCHAs.
FancyCaptcha
![](http://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/FancyCaptcha_screenshot.png/220px-FancyCaptcha_screenshot.png)
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).
- Add the following lines to
LocalSettings.php
in the root of your MediaWiki installation:wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/FancyCaptcha' ]);
$wgCaptchaClass = 'FancyCaptcha';
- In
LocalSettings.php
, set the variable$wgCaptchaDirectory
to the directory where you will store Captcha images. Note: use the absolute directorypath or relative to your wiki's installation directory Below it set$wgCaptchaSecret
to your passphrase. - Create the images by running the following:
python /path/to/captcha.py --font=<font> --wordlist=<wordlist> --key=<key> --output=<output> --count=<count>
- 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.
- 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
See also wikitech:Generating CAPTCHAs for how Wikimedia Foundation does it.
- How to avoid common problems running Python on Windows
- Install the most recent version of Pillow.
- 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
MathCaptcha
MediaWiki版本: | ≤ 1.39 |
This module generates an image using TeX to ask a basic math question.
Set the following to enable this CAPTCHA:
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/MathCaptcha' ]);
See the README
file in the math folder to install this captcha.
hCaptcha
MediaWiki版本: | ≥ 1.35 |
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.
Turnstile
MediaWiki版本: | ≥ 1.42 |
master
branch of the extension.The configuration is similar to #ReCaptcha or #hCaptcha:
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/Turnstile' ]);
$wgTurnstileSiteKey= 'your public/site key here';
$wgTurnstileSecretKey= 'your private key here';
$wgTurnstileSendRemoteIP
is also available.
組態
Don't require CAPTCHA from some users
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;
$wgAllowConfirmedEmail = true;
Set actions that require CAPTCHA
The following conditions can trigger a CAPTCHA to be displayed:
- 'edit' - triggered on every attempted page save
- 'create' - triggered on page creation
- 'sendemail' - triggered when using Special:Emailuser
- '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 after several failed login attempts from the same IP address
- 'badloginperuser' - triggered after several failed login attempts using the same username
The default values for these are:
$wgCaptchaTriggers['edit'] = false;
$wgCaptchaTriggers['create'] = false;
$wgCaptchaTriggers['sendemail'] = false;
$wgCaptchaTriggers['addurl'] = true;
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin'] = true;
$wgCaptchaTriggers['badloginperuser'] = 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和IP白名單
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).
- $wgAllowConfirmedEmail - 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.
Failed login attempts
When using the badlogin
or badloginperuser
triggers, the following configuration variables control how many failed login attempts per-IP and per-user are allowed before a CAPTCHA is required, and how long it takes until the CAPTCHA requirement expires:
$wgCaptchaBadLoginAttempts = 3;
$wgCaptchaBadLoginExpiration = 300; // 300 seconds = 5 minutes
$wgCaptchaBadLoginPerUserAttempts = 20;
$wgCaptchaBadLoginPerUserExpiration = 600; // 600 seconds = 10 minutes
The triggers require $wgMainCacheType to be set to something other than CACHE_NONE
in your LocalSettings.php
, if in doubt the following will always work.
$wgMainCacheType = CACHE_ANYTHING;
Note that these triggers not trigger CAPTCHAs on API login, but instead block them outright until the CAPTCHA requirement expires.
Wikimedia configuration
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.
速率限制
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
.
作者
The basic framework was designed largely by Brion Vibber, who also wrote the SimpleCaptcha and FancyCaptcha modules.
The MathCaptcha module was written by Rob Church.
The QuestyCaptcha module was written by Benjamin Lees.
Additional maintenance work was done by Yaron Koren.
參考資料
- ↑ MediaWiki:Questycaptchahelp-text, MediaWiki:Questycaptcha-edit, MediaWiki:Questycaptcha-addurl, MediaWiki:Questycaptcha-create, MediaWiki:Questycaptcha-createaccount
- ↑ Google Blog Are you a robot? Introducing 「No CAPTCHA reCAPTCHA」 ()
參見
![]() | 此擴充功能用於一個或多個維基媒體專案。 這可能意味着擴充功能足夠穩定、運作足夠良好,可以用在這樣的高流量的網站上。 請在維基媒體的CommonSettings.php和InitialiseSettings.php組態檔中尋找此擴充功能的名稱以檢視哪些網站安裝了該擴充功能。 特定wiki上的已安裝的擴充功能的完整列表位於Special:Version頁面。 |
![]() | 此擴充功能在以下wiki農場/寄存網站和/或軟件套件中提供: 這不是一份權威名單。 即使某些wiki農場/寄存網站和/或軟件套件未在這裏列出,它們也可能提供此擴充功能。 請檢查你的wiki農場/寄存網站或軟件套件以確認提供情況。 |
- Extensions bundled with MediaWiki 1.18/zh
- Stable extensions/zh
- Page action extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- APIGetAllowedParams extensions/zh
- AbuseFilterCustomActions extensions/zh
- AlternateEditPreview extensions/zh
- AuthChangeFormFields extensions/zh
- EditFilterMergedContent extensions/zh
- EditPage::showEditForm:fields extensions/zh
- EditPageBeforeEditButtons extensions/zh
- EmailUser extensions/zh
- EmailUserForm extensions/zh
- PageSaveComplete extensions/zh
- ResourceLoaderRegisterModules extensions/zh
- TitleReadWhitelist extensions/zh
- All extensions/zh
- Pages using deprecated NoteTA template
- Extensions used on Wikimedia/zh
- Extensions included in BlueSpice/zh
- Extensions included in Canasta/zh
- Extensions available as Debian packages/zh
- Extensions included in Fandom/zh
- Extensions included in Miraheze/zh
- Extensions included in MyWikis/zh
- Extensions included in ProWiki/zh
- Extensions included in semantic::core/zh
- Extensions included in ShoutWiki/zh
- Extensions included in WikiForge/zh
- Edit extensions/zh
- Spam management extensions/zh