Apache::Authen::Generic - A generic authentication handler for


Apache-Authen-Generic documentation  | view source Contained in the Apache-Authen-Generic distribution.

Index


NAME

Top

 Apache::Authen::Generic - A generic authentication handler for
   the Apache webserver (under mod_perl)

SYNOPSIS

Top

    # httpd.conf
    PerlModule Apache::Authen::Generic
    <Location /cgi-bin/secure>
            AuthType Basic
            AuthName "Test Login"
            PerlAuthenHandler Apache::Authen::Generic->authenticate
            require valid-user
            PerlSetVar generic_auth_cipher_key abcdefghijklmnopqrstuvwxyz012345
            PerlSetVar generic_auth_failed_url "/cgi-bin/login/login_form.cgi"
            PerlSetVar generic_auth_allow_url "^/cgi-bin/login"
            PerlSetVar generic_auth_cookie_name test_cookie
            PerlSetVar generic_auth_ref_url_var ref_url
            PerlSetVar generic_auth_set_cookie_env 1
    </Location>

    # cgi script
    use Apache::Authen::Generic;
    my $auth_obj = Apache::Authen::Generic->new;
    if (&check_login($user, $pwd)) {
        my $cookie = $auth_obj->($data, $key);
        print "Set-Cookie: $cookie\n";
        print "Location: $redirect_url\n";
        print "\n";
    } else {
        &handle_invalid_password()
    }

 # Efforts have been made to make this module work under Apache
 # 1.3.* and mod_perl 1.0, but it has only been tested under
 # Apache 2.0.* and mod_perl 2.0.

DESCRIPTION

Top

Variables to set in the Apache configuration file

 The following are variables to be set in the Apache
 configuration file with the PerlSetVar directive.

generic_auth_cipher_key

 This is the encryption key used for encrypting the cookies used
 to verify authentication.  It must be 32 bytes (256-bit).  The
 encryption used is AES-256 and uses an SHA1 digest to verify
 data integrity.

generic_auth_failed_url

 This is the url users are be redirected to if they have not been
 authenticated (typically a login page).  This url can be
 relative.

generic_auth_allow_url

 This is a regular expression that will be run against the URI
 the user is trying to access.  If a match occurs, the user will
 be allowed through, as if the user had been authenticated.  This
 is useful for allowing the user to access the login page and to
 allow access to other public pages.

generic_auth_ref_url_var

 This is the name of the field the handler will use to pass the
 current URI to the authentication failed page.  This is useful
 for redirecting the user to the page the user was originally
 trying to access when prompted with the login page.

METHODS

Top

authenticate($request_obj)

 The main interface to this module.  This is the method to be
 called as the authentication handler.  If you wish to subclass
 this module, the following information may be useful.

 The steps in authenticate() are as follows:

   1) Instantiates an Apache::Authen::Generic object by calling
      the new() method.
   2) Check if the user is already authenticated
      Calls $self->checkAlreadyAuthenticated($request_obj)
      Returns OK if return value is true
   3) Check if the current URI is always allowed through
      Calls $self->checkGloballyAllowedUrls($req)
      Returns OK if return value is true
   4) Redirect to login page if the above steps fail
      Calls $self->redirectToAuthFailedPage($req)
      Sets a Location header and returns OK

EXAMPLES

Top

AUTHOR

Top

 Don Owens <don@owensnet.com>

COPYRIGHT

Top

VERSION

Top

 0.01


Apache-Authen-Generic documentation  | view source Contained in the Apache-Authen-Generic distribution.