Extension:Lockdown

From MediaWiki.org

Jump to: navigation, search
If you need per-page or partial page access restrictions, you are advised to install an appropriate content management package. MediaWiki was not written to provide per-page access restrictions, and almost all hacks or patches promising to add them will likely have flaws somewhere, which could lead to exposure of confidential data. We are not responsible for anything being leaked, leading to loss of funds or one's job.
For further details, see Security issues with authorization extensions


Manual on MediaWiki Extensions
List of MediaWiki Extensions
Lockdown

Release status: beta

Implementation User rights
Description implements per-namespace group permissions
Author(s) Duesentrieb
MediaWiki 1.13 recommended, also works with 1.9-1.11, but not 1.12.
License No license specified
Download Download snapshot

Subversion [Help]
Browse source code
README
log

Hooks used userCan

The Lockdown extension implements a way to restrict access to specific namespaces and special pages to a given set of user groups. This provides a more fine grained security model than the one provided by the default $wgGroupPermissions and $wgNamespaceProtection settings.

Warning Warning:  broken for 1.12! Works again in 1.13, a patch for 1.12 exists.

The following pages about the security model used by MediaWiki per default may be helpful to understand the instructions below:

Contents


[edit] Installing

Copy the Lockdown directory into the extensions folder of your MediaWiki installation. Then add the following lines to your LocalSettings.php file (near the end):

require_once( "$IP/extensions/Lockdown/Lockdown.php" );
 
$wgSpecialPageLockdown['Export'] = array('user');
 
$wgNamespacePermissionLockdown[NS_PROJECT]['edit'] = array('user');

The settings for $wgSpecialPageLockdown and $wgNamespacePermissionLockdown are just examples - see below for details.

[edit] Configuration

Note that the Lockdown extension can only be used to *restrict* access, not to *grant* it. If access is denied by some built-in setting of MediaWiki, it cannot be allowed using the Lockdown extension.

[edit] $wgSpecialPageLockdown

$wgSpecialPageLockdown allows you to specify for each special page which user groups have access to it. For example, to limit the use of Special:Export to logged in users, use this in LocalSettings.php:

$wgSpecialPageLockdown['Export'] = array('user');

Note that some special pages "natively" require a specific permission. For example, Special:Userrights, which can be used to assign user groups, required the "userrights" permission (granted only to the "bureaucrat" group per default). This restriction can not be overridden using the Lockdown extension.


[edit] $wgNamespacePermissionLockdown

$wgNamespacePermissionLockdown lets you restrict which user groups have which permissions on which namespace. For example, to grant only members of the sysop group write access to the project namespace, use this:

$wgNamespacePermissionLockdown[NS_PROJECT]['edit'] = array('sysop');

Wildcards for either the namespace or the permission (but not both at once) are supported. More specific definitions take precedence:

$wgNamespacePermissionLockdown[NS_PROJECT]['*'] = array('sysop');
$wgNamespacePermissionLockdown[NS_PROJECT]['read'] = array('*');
 
$wgNamespacePermissionLockdown['*']['move'] = array('autoconfirmed');

The first two lines restrict all permissions in the project namespace to members of the sysop group, but still allow reading to anyone. The third line limits page moves in all namespaces to members of the autoconfirmed group.

Note that this way, you cannot *grant* permissions that have not been allowed by the build-in $wgGroupPermissions setting. The following does *not* allow regular users to patrol edits in the main namespace:

$wgNamespacePermissionLockdown[NS_MAIN]['patrol'] = array('user');

Instead, you would have to grant this right in $wgGroupPermissions first, and then restrict it again using $wgNamespacePermissionLockdown:

$wgGroupPermissions['user']['patrol'] = true;
 
$wgNamespacePermissionLockdown['*']['patrol'] = array('sysop');
$wgNamespacePermissionLockdown[NS_MAIN]['patrol'] = array('user');

Note that when restricting read-access to a namespace, the restriction can easily be circumvented if the user has write access to any other namespace: by including a read-protected page as a template, it can be made visible. To avoid this, you would have to forbid the use of pages from that namespace as templates, by adding the namespace's ID to $wgNonincludableNamespaces (this feature was introduced in MediaWiki 1.10, revision 19934, and is also available as an extension for earlier versions):

$wgNamespacePermissionLockdown[NS_PROJECT]['read'] = array('user');
$wgNonincludableNamespaces[] = NS_PROJECT;

You can of course also use Lockdown with custom namespaces defined using $wgExtraNamespaces:

#define custom namespaces
$wgExtraNamespaces[100] = 'Private';
$wgExtraNamespaces[101] = 'Private_talk';
 
#restrict "read" permission to logged in users
$wgNamespacePermissionLockdown[100]['read'] = array('user');
$wgNamespacePermissionLockdown[101]['read'] = array('user');
 
#prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[] = 100;
$wgNonincludableNamespaces[] = 101;

Note that custom namespaces should always be define in pairs, the namespace proper (with an even id), and the associated talk namespace (with an odd id).

If you want to use constants to refer to your namespaces, you need to define them:

#define constants for your custom namespaces, for a more readable configuration
define('NS_PRIVATE', 100);
define('NS_PRIVATE_TALK', 101);
 
#define custom namespaces
$wgExtraNamespaces[NS_PRIVATE] = 'Private';
$wgExtraNamespaces[NS_PRIVATE_TALK] = 'Private_talk';
 
#restrict "read" permission to logged in users
$wgNamespacePermissionLockdown[NS_PRIVATE]['read'] = array('user');
$wgNamespacePermissionLockdown[NS_PRIVATE_TALK]['read'] = array('user');
 
#prevent inclusion of pages from that namespace
$wgNonincludableNamespaces[] = NS_PRIVATE;
$wgNonincludableNamespaces[] = NS_PRIVATE_TALK;

[edit] Additional measures

[edit] Hiding pages

The Lockdown extension may prevent page content from being shown, but it does not remove inaccessible pages from listings. To hide such pages, several patches must be applied to MediaWiki. See Extension:Lockdown/hiding_pages for some (unofficial) suggestions.

[edit] Images and other uploaded files

Images and other uploaded files still can be seen and included on any page. Protections on the Image namespace do not prevent that. See Manual:Image Authorisation for information on how to prevent unauthorized access to images. See also Extension:Simple Security and Extension:SimpleSecurity4

[edit] Redirects

MediaWiki version: 1.10 and before

For MediaWiki 1.10 and earlier: If a redirect #REDIRECT [[PNS:P]] to a page P in a protected namespace PNS has been placed on an unprotected page and the page has been loaded, it will lead the user to the protected page, regardless the user belongs to the required usergroup or not.

This problem does not appear to exist in MediaWiki 1.11 or later.

Personal tools