[Home]WikiPatches/PrivateUserGroups

UseModWiki | WikiPatches | RecentChanges | Preferences

A patch/plugin for UseModWiki v 0.92

June 2003, [Chris Carter]

Overview

This is a patch to enable the locking of pages and subpages to create private user working groups. Sometimes you don't really want your work to be public, but want to use the power of wiki to get the job done. This patch lets you adapt this wiki to manage private working groups, perhaps needed in a more corporate setting.

This patch should ideally be used with the login patches, as it requires the username field for authentication.

I originally started using TWiki, which supports this sort of thing, but quickly decided that I hated it intensely. So, I hacked UseMod to get the job done instead. Enjoy!

Use

To enable a private page, create a subpage called AuthUsers?. On this page, list the usernames (not ids) that should have access. If this subpage exists and is not empty, all access to the main page and any other subpages off of it is restricted to those users listed in the AuthUsers? file.

Any other access is redirected to System/AuthError? for an access denied message. That page location can be easily changed in the script if desired, or create a new configuration variable for it. I just hard coded it in for now to make this simple.

For added security, administrators may want to lock the AuthUsers? file to prevent tampering. Administrators are not affected by the AuthUsers? patch, and can still access all pages.

Patches

These two enable the auth checks:

sub OpenPage {
  my ($id) = @_;
  my ($fname, $data);
  if (!CheckIsAuthUser($id)) { $id = "System/AuthError"; } #auth patch
  if ($OpenPageName eq $id) {

sub DoEdit {
  my ($id, $isConflict, $oldTime, $newText, $preview) = @_;
  my ($header, $editRows, $editCols, $userName, $revision, $oldText);
  my ($summary, $isEdit, $pageTime);
  if (!CheckIsAuthUser($id)) { $id = "System/AuthError"; } #auth patch

Here is the main subroutine itself:

sub CheckIsAuthUser {
  my ($id) = @_;
  if (!(&UserIsAdmin())) {
    my $aname = $id;
    $aname =~ s/(^[^\/]+)\/*[^\/]*$/$1/;
    my $afname = $PageDir . "/" . &GetPageDirectory($aname) . "/" . $aname . "/" . "AuthUsers.db";
    if (-r $afname) {
      my $auth = ""; my $isempty = "yes";
      if ($id =~ /^(.*)\/.*/) {
        my $aname = $1;
      }
      open (AFN,"<$afname");
      while (<AFN>) {
        if (/$FS1/) { next; }    # skip header and footer
        if (/^>\s[^\w]/) { next; }  # skip comments
        if (/^>\s([\w]+)/) {
          my $authname = $1; $isempty = "";
          if ($UserData{'username'} eq $authname) { $auth = 1; }
        }
      }
      close AFN;
      if ($isempty) { $auth=1; }
      return $auth;  
    }
  }
  return "1";
}

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 4, 2007 3:14 pm by MarkusLude (diff)
Search: