[Mediawiki-l] [quickhack] require a specific user to view a page
Jacob S
stormspotter at 6Texans.net
Thu Jan 27 16:16:34 UTC 2005
On Thu, 27 Jan 2005 15:58:25 +0100
Moritz Karbach <mailinglist at karba.ch> wrote:
> Hi,
>
> as my very private Wiki grew larger, a few people liked to use it as
> well. So I needed to protect the sites, that are really private. Since
> some kind of user rights is scheduled for version 1.5, here comes a
> quickhack:
>
> Wiki Version: 1.3.5 (maybe it works on later versions as well)
>
> Insert the following into Title.php, function userCanRead(), right
> after the globals have been defined (for me it's line 550):
>
> # inserted by m:o
> global $wgRequireUser;
> $siteName = $this->getPrefixedText(); # pagename
> $requiredUser = $wgRequireUser[$name];
> $allowed = true;
> foreach( $wgRequireUser as $siteRegExp =>
> $requiredUser ){
> $check= preg_match("/$siteRegExp/",
> "$siteName");
>
> if( $check==1 &&
> $wgUser->getName()!=$requiredUser ) {
> $allowed = false;
> }
> }
> if( ! $allowed ) return false;
> # /inserted by m:o
>
> Then insert the following in your LocalSettings.php at the end, just
> before the '?>':
>
> #
> # inserted by m:o
> #
> # set access rights
> #
> # usage:
> # "regular expression that matches the site you want to protect" =>
> "required user"
> #
> # examples:
> # "^Linux" matches all sites beginning with "Linux"
> # "Linux" matches all sites containing "Linux"
> # "Linux$" % ending with "Linux"
> #
> $wgRequireUser = array (
> "^Hauptseite:private$" => "Mo",
> "^Tbd$" => "Mo",
> "^Desy" => "Mo",
> "^Grid" => "Mo",
> "^Logbook$" => "Mo"
> );
Nice! I've been looking for something like this. (Sorry, I haven't
studied enough of the Mediawiki code to comment on the security aspect
yet.)
Thanks,
Jacob
More information about the MediaWiki-l
mailing list