From TestWiki
Jump to: navigation, search
This extension is not currently installed on this wiki.
MediaWiki logo.png
This extension is also documented at

If the pages are not in sync. then this version on my test wiki is always the most up-to-date.

This extension is no longer maintained, nor supported. The extension was originally written for MW v1.6 and should work fine on that version, however other versions are untested and it is known to not work on more recent versions of MediaWiki. If someone wants to take on and extend/improve or otherwise maintain this extension then they are welcome to do so, using the same name if they choose. I have another more sophisticated page-protection extension which I currently use but which I have not yet released to the community (mainly due to time constraints). I will try and get that out sometime soon, but no promises... --HappyDog 19:09, 14 April 2010 (UTC)

About the extension[edit]

DISCLAIMER - Please make sure you fully understand what this extension does and doesn't do before using it. As the author, I am not responsible for any misconceptions you may have and the consequences they may bring!

This extension adds a very crude per-page protection mechanism to your wiki.

What the extension does[edit]

  • It allows you to specify a list of users on each page which is either:
    1. a list of users who are allowed to view the page (in which case all other users are blocked).
    2. a list of users who are denied from viewing the page (in which case all other users can view it).
  • If a user is denied then they will get an 'access denied' error when they try to view the page.
    • This includes transcluding - transcluding a protected page will protect the page that is doing the transcluding in exactly the same way.
      • However - there is a fairly simple way to avoid this and allow transclusion of a protected page!
  • The 'edit' or 'view source' tabs are removed from the interface when this happens.

What it does not do![edit]

  • Although the 'edit' tab is removed from the interface, the code does not block any actions, so by editing the URL any user can edit the page.
    • This means that they can view the source (though 'show preview' will not work).
    • This also means they can remove the protection (in which case 'show preview' will work).
  • Someone who knows how to edit the URL can therefore view both the source and the rendered page without you knowing about it.
  • They can also view the history, rollback edits, move, delete or perform any other operation through the interface without needing to modify the URL.
  • If a user tries to view an old revision of a 'protected' page they will be able to view it so long as that revision was not explicitly protected in the page source. Viewing old revisions is possible from lots of places, including the page history and recent changes.
    • Therefore to add this protection to all versions of a page, make sure you add it in the first edit and that it is never changed or removed.
  • Administrators/bureaucrats/whatever have no special powers. If they are not on the list they are blocked from viewing.
  • The title of the page is always visible - you cannot hide that the page exists, or what it is called.
  • The page will still show up in any categories that it is listed in.
  • Although you can protect image pages, you cannot stop the image itself from being included in another page.
  • Behaviour is undefined if used in the MediaWiki namespace.

In short, this extension offers a very crude protection mechanism to stop casual browsing. It is the technical equivalent of a 'keep out' sign. Please read about mw:security issues with authorization extensions


I wrote this extension for use on my private wiki, which is used by several groups of people involved in different projects. I was uncomfortable with the fact that users could view details about projects they weren't involved in, particularly as some of them needed to be kept private. I also know all my users personally and trust them not to go snooping where they don't belong, so I created this extension as a kind of simple 'keep out' sign.


After installing the extension in the standard way, a new tag, <protect> is available to you. This flag has two optional arguments:

  1. type = "allow" or "deny" (default "allow").
    • "allow" means that only the listed users can view the page.
    • "deny" means everyone except the listed users can view the page.
  2. separator = (string)
    • Set this to the character or string that separates each user in the list.
    • The default value is a comma. This is most useful for situations where one of the usernames contains a comma.
    • You can use "\n" to use line-breaks as the separator (but not in conjunction with any other symbols, e.g. ",\n" won't work).


 # Allow only John, Bob and Terry to view the page
 <protect>John,Bob, Terry</protect>

 # Allow everyone except "John, Jr." and "Alan" to view the page.
 # We use the pipe symbol because John, Jr. has a comma in his name.
 <protect type="deny" separator="|">John, Jr.|Alan</protect>

Whitespace is trimmed from each username, so line-breaks and other friendly layouts are allowed.

Note - only the first protect block in each page is used - all others are stripped from the rendered page, but are otherwise ignored.

Source code[edit]

Live sourcecode viewer: CrudeProtection.php
Last modified: 2021-04-08 10:18:49