Open main menu

Extension:PageProtection

MediaWiki extensions manual
OOjs UI icon alert-invert.svg
PageProtection
Release status: unstable
Implementation Tag , User rights
Description Protect areas and sections from access
Latest version 1.4 (2006-05-24)
MediaWiki 1.6.3
License No license specified
Download No link
Translate the PageProtection extension if it is available at translatewiki.net
Check usage and version matrix.

Note: This extension cannot be downloaded anymore; Domain is unregistered, modified version can be found on /Sourcecode (Jonabbey).

PageProtection is an extension for MediaWiki (1.6.3) which enables you to protect specific areas by only allowing access to certain users / groups.

The extension is implemented as parser and hook in AlternateEdit. You can have multiple protected and unprotected areas on a single article where only allowed users see the protected areas, all other users see the rest.

DownloadingEdit

The whole code with installation-instructions is now available from the following link:

This extension cannot be downloaded anymore; domain is unregistered.

FeaturesEdit

  • Protect pages / sections / textblocks
  • Store protected texts RSA-encoded in database
    • not searchable
    • not displayed in diffs
    • if extensions is not loaded/fails/is deactivated, the content will not be displayed, but only the RSA-encoded text
  • Mark sections as readonly

UsageEdit

Surround text that should be protected by <protect users="..." groups="...">, </protect> tags.

Parameters
users Comma-separated list of allowed users.
groups Comma-separated list of allowed groups. 'sysop' will be automatically in this list, don't need to specify.
show What to print for users that don't have access. Possible Values:
  • none - nothing is printed
  • warning - Error-message is printed
  • text - Plain-text is displayed but section is not editable (readonly)
  • crypt - RSA-encrypted string is printed (debugging ...)
  • page - Content of another page is printed
errorpage - Page to be displayed - can have {{{users}}} and {{{groups}}} as parameters.

The extension also registers the messages ProtectedSite and ProtectedSiteEditing that will be displayed for unauthorized users. These messages have two variables that will be replaced:

{{{USERS}}}
List of users that can access the area (links to ther user-pages)
{{{GROUPS}}}
List of groups that can access the area

ProtectedSite will be displayed when unallowed users want to read protected contents with show="warn" and ProtectedSiteEditing will be displayed when unallowed users want to edit protected contents.

ExampleEdit

The following code would give admin1 and admin2 and all users of sysop read /write access to an area. All other users would see an information instead.

<protect users="admin1,admin2" groups="sysop">
Database-Settings
;Server
: localhost
...
</protect>

CodeEdit

ChangelogEdit

1.4
 - Working with PHP4
1.3
 - Parameter show="none" did not work
 - Minor bugfixes in code and installation-manual
1.2
 - Redesign of internal structure (more classes)
 - Added value "text" to parameter "show" that allows marking sections as
readonly.
 - Disabled editing of sections as this adds currently unfixable security holes.

1.1
 - PEM-file for storing PEM-data now is automatically created
 - Bugfix
1.0
 - Texts are stored RSA-encrypted in database
 - When saving articles, the current user is automatically added
     to the permitted users.
 - Added parameter show=[warning, none, crypt, page] and parameter
             errorpage

InstallationEdit

RequirementsEdit

Needs at least MediaWiki 1.6 to run as it uses a hook to AlternateEdit which is first available in version 1.6 and later.

You need to have the following modules installed:

Simply download, and unpack, keeping directory structure.

They have to be in the include-path. I placed them in mediawiki/pear and mediawiki/crypt. Additionally you have to create a file containing your private and public key that is localed in the mediawiki-folder.

Directory structure of my wiki
/mw
  |- index.php
  |- PEAR.php
  |- PEAR/
  |    | ...
  |- Crypt
  |- extensions
  |    |-  PageProtection
  |    |     |- PageProtection.php
  |   ...
 ...

... the installationEdit

Save the above code in extensions/PageProtection/ and add the following to LocalSettings.php

    // disable caching
    $wgCachePages       = false;
    $wgCacheEpoch = 'date +%Y%m%d%H%M%S';
    
    // Activate PageProtection extension.
    require_once("extensions/PageProtection/PageProtection.php");

I had to add the above deactivation of the cache as $parser->disableCache(); did not work for me. Better suggestions are welcome ;)

Tested environmentsEdit

The extension has been successfully tested in the following environments:

  • Gentoo Linux
    • MediaWiki 1.6.3, 1.7alpha (r14141)
    • Apache 2.0.55
    • PHP 5.1.2
    • MySQL 5.0.19
  • SuSE Linux with XAMPP 1.5.2
    • MediaWiki 1.6.3
    • Apache 2.2.0
    • PHP 5.1.2
    • MySQL 5.0.20
  • Windows 2000 with XAMPP 1.5.2
    • MediaWiki 1.6.3
    • Apache 2.2.0
    • PHP 5.1.1
    • MySQL 5.0.20
  • Windows 2000 with XAMPP 1.5.1
  • Fedora Core 5
    • MediaWiki: 1.6.6, 1.7.1
    • Apache/2.2.0, 2.2.2
    • PHP: 5.1.4 (apache2handler) in safe mode , needed to instal PEAR in homedir because of user restrictions (i am not superuser), as described in install steps
    • MySQL: 5.0.22
  • Debian GNU/Linux 3.1r2 Etch
    • MediaWiki: 1.6.7
    • Apache/2.0.55
    • PHP 5.1.4
    • MySQL 5.0.22
  • Debian GNU/Linux 2.4.27-i686
    • MediaWiki: 1.6.7 (used Parser.php from 1.6.6 cos PP-patch for MW1.6.7 didn't work for me)
    • Apache/2.0.54 mod-ssl
    • PHP 4.3.10 (had to add the file_put_contents() function)
    • MySQL 5.0.19
    • don't know your test methods, but works for groups/edit/diff --Nad 02:55, 12 August 2006 (UTC)
  • Ubuntu Linux 6.10 Edgy Eft
    • MediaWiki: 1.8.2
    • PageProtection: 1.4.2
    • Apache/2.0.55 mod-ssl
    • PHP 5.1.6
    • MySQL 5.0.24
  • Debian GNU/Linux 4.0 Etch
    • MediaWiki: 1.12.0
    • PageProtection: 1.4-2
    • Apache/2.2.3 (Debian) mod_ssl/2.2.3 OpenSSL/0.9.8c WebAuth/3.5.3
    • PHP 5.2.0-8+etch10
    • MySQL 5.0.32-Debian_7etch5-log

See alsoEdit