MediaWiki Spam Prevention

From Linux Delta
Jump to: navigation, search

The basics of protecting Media Wiki from SPAM, using account confirmation feature and the Moderation extension.

These changes have been tested against MediaWiki v1.34

Download and install the Moderation Extension[edit]

wget https://github.com/edwardspec/mediawiki-moderation/archive/v1.4.20.zip
unzip v1.4.20.zip
mv mediawiki-moderation-1.4.20/ /srv/mediawiki/extensions/Moderation
rm v1.4.20.zip

Update the MediaWiki database schema[edit]

php /srv/mediawiki/maintenance/update.php

Update the MediaWiki settings file[edit]

Patch the following into LocalSettings.php:

$wgEnableEmail = true;
$wgEmergencyContact = 'wiki-admin@mywebsite.com';	# judging by the docs, this is misnomered and 
							# in most situations should be the same as 
							# $wgPasswordSender
$wgPasswordSender = 'wiki-admin@mywebsite.com';

Append the following into LocalSettings.php

# Filter out changes containing certain key words
$wgSpamRegex = "/".
                "a|regex|containing|forbidden|words|and|layout|\/|formating".
                "/i";

# Block spam edits from black listed IP addresses
$wgEnableDnsBlacklist = true;
$wgDnsBlacklistUrls = array( 'xbl.spamhaus.org', 'dnsbl.tornevall.org' );

$wgEmailConfirmToEdit = true; 	# Unfortunately you can't force users to 
				# provide an email address when they create 
				# an account, but this should ensure they
				# have a confirmed email address before they 
				# can edit

# You need to specify a mail server for sending confirmation email
$wgSMTP = [
    'host'     => 'submission.someserver.somewhere',
    'IDHost'   => 'mediawiki.domain.somwhere',
    'port'     => 587,
    'auth'     => true,
    'username' => 'username',
    'password' => 'password'
];

wfLoadExtension( 'Moderation' );

Now test your changes.

Further Reading[edit]

https://www.mediawiki.org/wiki/Email

https://www.mediawiki.org/wiki/Extension:Moderation

https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgSMTP

https://www.mediawiki.org/wiki/Manual:Combating_spam