IIT::Auth - A Simple IIT Authentication Module
use IIT::Auth; # Create new IIT::Auth object and log a user in using the supplied # $username and $password. my $auth = new IIT::Auth (Username => $username, # Username Password => $password, # Password SessionDir => '/tmp'); # Session Directory # Get the session id my $authid = $auth->auth_id; # Open an existing session using a $knownid my $auth = new IIT::Auth (AuthID => $knownid, SessionDir => '/tmp'); # Session Directory # Get the session id as a hidden form field my $auth_field = $auth->auth_field; # Get the current user's username my $username = $auth->username; # Get the auth status. Returns 1 for a valid login and 0 for # invalid login. This is here for future development. my $status = $auth->status;
This module can be used in conjunction with a POP3 server to authenticate users.
To create a new authenticated session, the module must be provided at least a username and a password. Once a user has been sucessfully authenticated with the POP3 server, his or her credentials are saved to a file on the server. The contents of this file are encrypted (this is done via the CGI::Session::Secure module). A unique authenticated session id is generated for this session.
To activate an existing session the module must be provided a valid session id (previously authenticated). The module will reload the saved session using this session id.
The IIT::Auth module requires the following modules to function correctly:
CGI::Session::Secure - To create secure persistent sessions
Net::POP3 - To connect and authenticate against a POP3 server
Note: At the time that this documentation was completed, the module CGI::Session::Secure was not a standard CPAN module. It should be downloaded from the author of this module.
These methods are open to be used by the programmer.
new(%options)
The IIT::Auth constructor may be called with the following arguments:
This is an existing authenticated session id. It can be retrieved using the auth_id method. This id will be used to open an existing session that has been saved on the server. This argument will override the Username and Password arguments if they are provided.
auth_id
The username to be used for authentication. The username is NOT an email address. In most cases it will be what is before the '@' in an email address.
The password corresponding to the above Username.
This is the directory where the sessions will be saved. This argument is passed as the Directory argument to the CGI::Session::Secure module. It defaults to the system's temporary directory.
This is the type of the person being authenticated. It may be either one of the strings 'Staff', 'Student' or 'Both'. Internally, these strings correspond to the pop3 server against which the user is to be authenticated. This value defaults to 'Both'.
A reference to a list of pop3 servers against which authentication should be attempted. If AuthType is provided, then the servers corresponding to the specified type will be appended to this list.
username
This method returns the username of the currently authenticated user. This value is saved to the authenticated session and can be retrieved when a session is activated using the AuthID.
my $username = $auth->username;
originator
This method is experimental. It returns the name of the program that created the session. It will not change once a session has been created.
my $program = $auth->originator;
auth_field
This method returns a hidden field to be included in an HTML form. This field holds the authenticated session id and can be used to retrieve a previously authenticated session.
my $hidden_field = $auth->auth_field;
This method returns the authenticated session id.
my $authid = $auth->auth_id;
status
This method returns the current login status. A true (1) value indicates that the session is valid. A false (0) values indicates that the session is invalid.
my $status = $auth->status;
logout
This method logs the current user out. This involves deleting the session file and resetting the status.
$auth->logout;
These methods should NOT be used by your program. They are for internal use by the module
_initnew
Initializes a new session and creates a new session id.
_initold
Initializes an old authenticated session.
None to report so far..
Prasad Ullal CPAN ID: None yet prasad.ullal@iit.edu
Copyright (c) 2002 Prasad Ullal. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
CGI::Session::Secure, Net::POP3
To install IIT::Auth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IIT::Auth
CPAN shell
perl -MCPAN -e shell install IIT::Auth
For more information on module installation, please visit the detailed CPAN module installation guide.