external_creation_check how to

About this HowTo

MoinMoin versions
1.9.4
Platforms
Debian Linux (only)

Since about 1.9.3 (or somewhere in the 1.9 series I think) moinmoin has been able to run a custom script on account creation. As I could not find any docs I used the source and this is my How To.

This is a Debian patch and NOT part of the official MoinMoin wiki, but it would be nice to have!

The purpose of external_creation_check

When users self register accounts administrators may want to implement some kind of policy control based on the requested account name, email address or IP address. Moinmoin provides this facility via the external_creation_check hook.

In you wiki config simply add a line:

external_creation_check = '/path/to/my/script'

This script will then be run on accuont creation.

Confusigly the script exit status is totally ignored! Failure is signified by writng a message to stdout of the script. This message is then shown to the user and no accuont is created. Sucsess is signified by the script not outputting on stdout.

Three pieces of information are passed into the script as command line arguments:

  1. name
  2. email
  3. IP address

Example external_creation_check script

 #!/bin/bash
#moinmoin  external_creation_check
# Inputs:  $1=name
#          $2=email
#          $3=IP address
# Outputs: Nothing=sucsess
#          error message string to stdout on failure
# NB:      Exit status is ignored, but still we do the right thing.

AUTH_EMAIL=/path/to/list_of_email.txt #one address per line

if  grep -q -i  "$2" "$AUTH_EMAIL"   ; then
        logger -p user.info -t mywiki "SUCCESSFUL REGISTRATION: NAME=$1 EMAIL=$2 IP=$3"
        
else
        echo "UNAUTHORSED EMAIL ADDRESS: PLEASE REGISTER WITH SITE ADMIN"
        logger -p user.warn -t  mywiki "FAILED REGISTRATION: NAME=$1 EMAIL=$2 IP=$3"
        exit 1 #This is ignored but is the right thing to do
fi
exit 0

MoinMoin: HowTo/ExternalCreationCheck (last edited 2013-11-14 12:32:30 by dslb-092-077-141-164)