Search code examples
mediawikiwikimediawiki-extensions

Prevent External Users from Updating or adding Wiki Pages


Several years ago, I used mediawiki to create a wiki. I had(still have) no idea really how to administrate it. I wanted it to be maintained/updated by only myself. It was to hold a specific set of information for my users.

After a few weeks it became flooded with User submitted pages (in this case not a good thing) and I guess what you'd call "spammers"(?).

How can I set it up so that only a legitimate admin (me) can add/update page?

I thought I had enabled something to do that...but it apparently didn't work.


Solution

  • In MediaWiki, permissions (read, edit, createpage, etc.) can be granted or refused by configuring the $wgGroupPermissions array in your LocalSettings.php file.

    There is a set default groups that you can use with $wgGroupPermissions to restrict page creation/editing:

    * - all users (including anonymous)

    user - registered accounts

    autoconfirmed - registered accounts at least as old as $wgAutoConfirmAge and having at least as many edits as $wgAutoConfirmCount

    bot - accounts with the bot right (intended for automated scripts)

    sysop - users who by default can delete and restore pages, block and unblock users, et cetera

    bureaucrat - users who by default can change other users' rights

    The group that would apply to only you (as the creator of the wiki) is the sysop group.

    For example, to refuse createpage/edit rights for all users except those with the sysop group, you would place this in your LocalSettings.php:

    # Deny createpage and edit rights to all users
    $wgGroupPermissions['*']['createpage'] = false;
    $wgGroupPermissions['*']['edit'] = false;
    
    # Allow only users with the sysop group createpage and edit rights
    $wgGroupPermissions['sysop']['createpage'] = true;
    $wgGroupPermissions['sysop']['edit'] = true;
    

    The "*" character indicates that this rule will apply to all groups. Then, we add an exception to that rule for the "sysop" group, allowing users with that group to create or edit pages.