#!/usr/bin/perl # ezpiii.pl # (c) 1999-2000 Useful Utilities # http://www.usefulutilities.com # This script uses the Innovative Interfaces Inc. (III) patron authentication # interface to authenticate users. # Uncomment the "$debugfile = " line (and change the filename if you want) to # have debugging information recorded # $debugFile = "/tmp/ezproxy.dbg"; # ezpauth.pl really should be moved to a directory other than your # CGI directory. If you do this, be sure to change the following # line to reflect this new directory require "ezpauth.pl"; sub ShowForm; sub ExpiredID; sub WrongPatronType; # To link EZproxy to this script, you need to make an entry in ezproxy.usr # that looks like: # # cgiuser:cgipass:cgi=http://auth.mylib.org/cgi-bin/ezpiii.cgi? # # This line indicates that all new authentication requests should be # handed off to the specified CGI script. The ? at the end is required # since EZproxy will then append &url= followed by the web site the # user wants to visit. # # $ezpuser and $ezppass have to be set to match the username and password # from the ezproxy.usr entry. $ezphost must be your EZproxy server's # host name. $ezpuser = "cgiuser"; $ezppass = "cgipass"; $ezphost = "ezproxy.mylib.org"; ParseFields(); # If the user field is undefined, show the main form if (! defined $in{"idnumber"}) { ShowForm(0); exit(1); } # It's a good idea to validate your library card number first as a protection # for the III interace. This checks that there are 1 to 20 digits. If that # passes, then we let III finish validation. if ($in{"idnumber"} =~ /^\d{1,20}$/) { $result = AuthIII("iii.mylib.org", $in{"idnumber"}, $in{"lastn"}); } else { # If input user is not ten digits, it must be invalid so set $result to # the invalid library card code of 1. $result = 1; } # If the user was validated, call StartSession to have EZproxy create a new # new session for the user then redirect the user on to the desired URL if ($result == 0) { StartSession(); } elsif ($result == 2) { # The library card number is expired, so report this ExpiredID(); } elsif ($result == 3) { WrongPatronType(); } else { # The library card number was invalid, so report this and let the user try # again ShowForm(1); } sub ShowForm { print < Patron Authentication

Patron Authentication

EOF if ($_[0]) { print < EOF } $encurl = FormEncode($in{"url"}); print <
First Name:
Last Name:
CSU ID Number:

EOF } sub ExpiredID { print < Expired Your library card has expired. Please bring your card to the library to have it renewed. EOF } sub WrongPatronType { print < Unauthorized Patron Class You are not authorized for remote access to this database. EOF }