Apache-Authen-Generic

 view release on metacpan or  search on metacpan

Generic.pm  view on Meta::CPAN

# -*-perl-*-
# Creation date: 2003-09-30 07:55:27
# Authors: Don
# Change log:
# $Id: Generic.pm,v 1.11 2003/10/19 07:03:52 don Exp $

# Copyright (c) 2003 Don Owens

# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl
# itself.

=pod

=head1 NAME

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

=head1 SYNOPSIS

    # 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.

=head1 DESCRIPTION

=head2 Variables to set in the Apache configuration file

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

=head3 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.

=head3 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.

=head3 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.

=head3 generic_auth_cookie_name

 This is the name of the cookie that will be used to verify
 authentication.  This must match the name passed to the
 generateAuthCookie() method when using a CGI script for the
 login process.

=head3 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.

=head3 generic_auth_set_cookie_env

 If this is set to a true value, and the first argument passed to
 the generateAuthCookie() method is a hash, those values will be
 available to your CGI scripts as environment variables whose
 names are the keys of the hash prefixed with the cookie name (as
 set by generic_auth_cookie_name) and an underscore.

=head1 METHODS

=cut



( run in 0.605 second using v1.01-cache-2.11-cpan-39bf76dae61 )