Apache2::AuthEnv - Perl Authentication and Authorisation via Environment Variables.


NAME

Apache2::AuthEnv - Perl Authentication and Authorisation via Environment Variables.


SYNOPSIS

 ### In httpd.conf file (required to load the directives).
 PerlOptions +GlobalRequest
 PerlModule Apache2::AuthEnv
 ### In httpd.conf or .htaccess: ################
 # Set the remote user and trigger the auth* stages
 AuthEnvUser %{REMOTE_ADDR}@%{SOME_ENV_VAR}
 # turn on logging
 AuthEnvLogInfo On
 # Also possible is setting the remote user from a list 
 # of alternative environment variables or a default value.
 AuthEnvUser %{HTTP_XX_USER|HTTP_YY_USER:anon}
 # Set extra environment variables.
 AuthEnvSet     HTTP_AE_SERVER  %{SERVER_ADDR:unknown}:%{SERVER_PORT:unknown}
 AuthEnvChange  HTTP_AE_SERVER  s/:/!/g
 AuthEnvChange  HTTP_AE_SERVER  tr/a-z/A-Z/
 # Load environment settings from a DBM database.
 AuthEnvDbImport   HTTP_EXTRA_ /etc/dbfile Key
 # Allow and Deny access based on environment.
 # The default is to deny access.
 # Allow and deny rules are evaluated based on their order in this file.
 AuthEnvAllowUser       fred@here.org
 AuthEnvDenyUser        george@here.org
 AuthEnvAllowMatch      %{HTTP_USER_AGENT}      ^Mozilla
 AuthEnvDeny            %{REMOTE_ADDR}          192.168.2.3
 AuthEnvDenyMatch       %{HTTP_USER_AGENT}      Fedora
 AuthEnvAllow           %{SERVER_PORT} 80
 AuthEnvAllowSplit      %{HTTP_MEMBEROF}   '\^' 'CN=....'
 AuthEnvAllowAll
 AuthEnvDenyAll
 AuthEnvDenial          UNAUTHORISED|UNAUTHORIZED|NOT_FOUND|FORBIDDEN


DESCRIPTION

Apache2::AuthEnv allows you to promote a string composed of CGI environment variables to act as an authenticated user. The format is set via the AuthEnvUser command and the result is placed in the environment variable REMOTE_USER.

This module is for use only when another Apache module pre-authenticates and pre-authorises a user but does not provide authentication nor authorisation controls within Apache.

This module, once loaded, is triggered by the Apache directive AuthEnvUser setting a format from the environment for the remote user name. Authorisation is controlled by AuthEnvAllow* and AuthEnvDeny* directives. The default is to deny authorisation to everyone.

  AuthEnvUser           %{HTTP_SSO_USER}@%{HTTP_SSO_ORG}
  AuthEnvAllowUser      fred@ORG

Such a system is Computer Asscoiates' SiteMinder (c) Single Sign On solution. Only pre-authenticated and pre-authorised users are allowed through to protected URLs. However there is no local control by the local web server. SiteMinder sets various environment variables including HTTP_SM_USER and HTTP_SM_AUTHDIRNAME. So a reasonable setting would be

  AuthEnvUser           %{HTTP_SM_USER}@%{HTTP_SM_AUTHDIRNAME}
  AuthEnvAllowUser      fred@ORG

Another example is
AuthEnvUser%{HTTP_UI_PRINCIPAL_NAME}
AuthEnvAllowUserfred@ORG.org
AuthEnvAllow%{HTTP_UI_DEPARTMENT} sales

Some systems may take authentication information from various sources and provide different environment variables for each source. So you can list alternative variables to use. AuthEnvUser %{HTTP_SOURCE1_NAME|HTTP_SOURCE2_NAME|HTTP_SOURCE3_NAME}

If nothing matches then you can set a default value (say 'anon') via
AuthEnvUser%{HTTP_SOURCE_NAME|HTTP_SOURCE2_NAME:anon}

For nested directives, configurations are inherited from one configuration file to the next. AuthEnvUser directives overwrite each other as do collections of AuthEnvAllow* rules. Each individual AuthEnvSet and AuthEnvChange directive, unless overwriten, is inherited.

The default denial code returned to the browser is FORBIDDEN. The directive AuthEnvDenial can be used to change the return code. For example,

  AuthEnvDenial         NOT_FOUND


FORMAT

The substitution format is composed of strings of characters and variable substitutions starting with '%{' and ending in '}'. Substitutions are of the following formats:

In the first case, the value of the environment variable is simply substituted. If a '|' separated list of variables is specified then each variable is checked in order, substituting the value of the first that is not empty. If no substitution succeeds and there is a default specified then that value is used instead.

To use formats with spaces in the .htaccess file, enclose the format in double quotes.


METHODS


APACHE DIRECTIVES

In the Apache configuration file httpd.conf, the module must be loaded

PerlOptions +GlobalRequest

PerlModule Apache2::AuthEnv


AUTHOR

Anthony R Fletcher arif@cpan.org


COPYRIGHT

Copyright (c) 2008 Anthony R Fletcher. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. It is supplied on an-is basis and there is no warrenty of any kind.

SiteMinder (c) is owned by Computer Asscoiates. This module does not rely on or use any part of SiteMinder and works purely via the environemnt within mod_perl.


SEE ALSO

perl(1), mod_perl(1), Apache(1).

 Apache2::AuthEnv - Perl Authentication and Authorisation via Environment Variables.