Extension:NSFileRepo

What can this extension do?
The NSFileRepo extension implements a way to restrict access to specific files and images to a given set of user groups. This provides a more fine grained security model and allows access restriction to users in specified groups.

Usage
Generically, you use the same syntax as a normal file/image reference link, adding the namespace between the file specifier ("File","Image", or "Media"), and the file name:

{FILE_NS}:{Namespace}:{Filename}

Example(Where "Project" is the protected namespace and "ProjectFile.pdf" is the file to which you wish to limit access):

The standard for accessing files/images is generally: [[Media:Filename.pdf]]

This extension allows you to protect access to files/images, by adding the namespace text identifier after the file namespace identifier, for example(Where "Project" is the protected namespace and "ProjectFile.xxx" is the file to which you wish to limit access): [[Media:Project:Filename.pdf]]

It may be helpful to understand the default security model used by MediaWiki using the instructions below:


 * Manual:User rights
 * Manual:$wgGroupPermissions

Limitations of security are the same as for Extension Lockdown. To review these limitations, please reference here.

To use the full capabilities of this extension (e.g., specific namespace protections), you will need to install and use the namespace protections provided through Extension:Lockdown.

This extension was made possible by the introduction of Repository Classes by Tim Starling - an elegant and brilliant implementation. It uses a new Local Repository class mechanism. Technical details on how this extension works can be found here.

Announcements

 * The first version of this (Rel 0.0) was released 2009-07-11. The following activities are underway to make this extension easier to install and use, including:
 * Modifying and updating the standard version of img_auth.php to include localization and a hook necessary for this extension. Will hopefully be approved for version 1.16
 * Discussing ways to allow modification of wfStripIllegalFilenameChars so that future patching will not be needed.

Download instructions
This Extension and the necessary patch/files may be downloaded from one of the following (SVN preferred)


 * Revision 0.0 (beta)
 * tar (May require eol conversion)
 * zip
 * SVN

Copy all files and directories into directory:

$IP/extensions/NSFileRepo

Installation
You will need to read and understand two other required enhancements to MediaWiki:


 * Image Authorization.
 * Extension Lockdown

Please read and understand before executing the following instructions


 * 1) Download and install  Extension Lockdown
 * 2) Download and copy the NSFileRepo extension into directory $IP/extensions/NSFileRepo
 * 3) Activate the Image Authorization according to instructions found in  Image Authorization
 * 4) Copy the img_auth.php and img_auth.i18.php from the distribution in directory {release}/phase3/ to your wiki code base directory ($IP).  This will overwrite the existing img_auth.php file.  Alternately you could copy img_auth.php to another name in the same directory, then use that file name instead of img_auth.php (but still must be in the $IP directory and the localization file must still be img_auth.i18.php).
 * 5) $IP/include/GlobalFunctions.php Must be patched.  This is a very minor patch to remove the disabling of colons (':').  You can do this one of three ways (whichever you're most comfortable with):
 * 6) Edit the file according to instructions  below
 * 7) If you have not otherwise patched the file, you may want to copy it from the distribution, which will be in a directory corresponding to the release you are using under {release}/phase3/includes/GlobalFunctions.php
 * 8) Apply the patch which will be in a directory corresponding to the release you are using under {release}/phase3/includes/GlobalFunctions.patch
 * 9) To activate this extension, add the following to LocalSettings.php:

Configuration parameters
The user rights and configuration requiremements are are the same as described in Extension Lockdown.

Patch GlobalFunctions.php
In version 1_13_0, a new function wfStripIllegalFilenameChars was added to includes/GlobalFunctions.php. This prevents the protection namespace from being detectd.

Index: GlobalFunctions.php

=
====================================================== --- GlobalFunctions.php	(revision 52849) +++ GlobalFunctions.php	(working copy) @@ -3034,6 +3034,6 @@ */ function wfStripIllegalFilenameChars( $name ) { $name = wfBaseName( $name ); -	$name = preg_replace ( "/[^".Title::legalChars."]|:/", '-', $name ); +	$name = preg_replace ( "/[^".Title::legalChars."]/", '-', $name ); return $name; } You need to remove the "or :" clause from the REGEX expression by deleting the characters "|:"