#!/usr/bin/perl
#
# $Id: sru-auth,v 1.1 2007-08-21 12:21:56 mike Exp $

# In order to test the authentication feature of Simple2ZOOM, we need
# an authenticator script, accessible via HTTP.  The simplest way to
# provide that is as a simple bit of HTML::Mason running under the
# conveniently available IRSpy distribution.  Since this is only for
# testing, a hardwired user register is good enough.

use strict;
use warnings;
use CGI;

my %register = (
    mike => "fish",
    simon => "frog 123",
    admin => "Tom&jErry",
);

my $cgi = new CGI();
my $user = $cgi->param('user');
my $pass = $cgi->param('pass');

if (defined $user && defined $pass && $register{$user} eq $pass) {
    print $cgi->header();
    print "OK\n";
    warn "good";
} else {
    print $cgi->header(-status => "401 Authorization Required"),
    warn "bad";
}
