Extension:Username Blacklist

The username blacklist provides a means for wiki administrators to restrict the creation of user accounts where the username matches one or more regular expressions.

Skip to the Download

Readme
USERNAME BLACKLIST EXTENSION

Version 1.6 © 2006-2007 Rob Church

This is free software licensed under the GNU General Public License. Please see http://www.gnu.org/copyleft/gpl.html for further details, including the full text and terms of the license.

Overview
1. Introduction 2. Requirements 3. Installing the Extension 4. Editing the Blacklist 5. Customising Warning Messages 6. Further Reading 7. Change Log 8. Thanks...

1. Introduction
The username blacklist extension is an add-on to the MediaWiki software which allows wiki administrators and other users with appropriate permissions to maintain a "blacklist" of usernames which cannot be registered. This blacklist is checked against and enforced during new account creation.

Privileged users are permitted to override the blacklist when creating accounts manually. By default, this permission is available to sysops, but can be restricted further or removed to prevent any override.

The blacklist accepts simple text and more powerful regular expressions, for matching against particular patterns of usernames.

2. Requirements
The username blacklist extension requires MediaWiki 1.5.8 or above.

3. Installing the Extension
To install the extension, place all extension files in a "UsernameBlacklist" directory within your MediaWiki extensions directory, then edit LocalSettings.php and add the following line:

require_once( "{$IP}/extensions/UsernameBlacklist.php" );

4. Editing the Blacklist
The username blacklist extension looks for a system message named "usernameblacklist" in your wiki. This can usually be edited via the MediaWiki:Usernameblacklist page. You will need to create this page, and format it as a bulleted list with each blocked username or regular expression as a new list item. For example:


 * Foo
 * [Bb]ar

The example above would prevent creation of the user account "Foo", and any account where the username contains "Bar" or "bar".

Lines without the list token (*) will be ignored when constructing the regular expression, which allows for adding comments or other explanations to the message page.

5. Customising Warning Messages
When a user attempts to create an account with a blacklisted username, they receive a warning message. The text of this can be customised via two system messages:

The heading text Explanatory text
 * MediaWiki:Blacklistedusername
 * MediaWiki:Blacklistedusernametext

6. Further Reading
As noted above, the extension supports regular expression text matching on usernames. I won't go into more detail about this here (and I have given an example above), but I'll provide a couple of useful links:

Wikipedia article on regular expressions: http://en.wikipedia.org/wiki/Regular_expression Brief introduction to regular expressions http://etext.lib.virginia.edu/services/helpsheets/unix/regex.html The 30 minute regex. tutorial: http://codeproject.com/dotnet/RegexTutorial.asp

7. Change Log
1.1	Make extension compatible with MediaWiki 1.5.8 Allow commenting out lines in the blacklist with # 1.2	Rewrite code for performance Allow users with the "uboverride" permission to pass the blacklist (manual account creation) 1.3	Support caching the blacklist in shared memory, e.g. memcached, APC etc. 1.4 Fix fatal error due to calling an undefined function

1.5	Don't block all usernames when the blacklist contains blank lines Use Unicode-friendly regular expressions Don't show errors when the blacklist contains only comments (Above fixes from Brion Vibber) 1.6	Support multiple language translations 1.7	Ignore all non-list lines when constructing the regular expression

8. Thanks...
* Avar; whose other extensions provide better reference than the docs * To the poster on mediawiki-l who inspired it	* Brion, for fixing a couple of bugs

All feedback welcome via .

Download
The latest version of the extension is available from MediaWiki's Subversion repository. The URL to the web-based viewer for this is http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/UsernameBlacklist.