Apache2::AuthCookie::Base - Common Methods Shared by Apache2 and Apache2_4 AuthCookie Subclasses.
version 3.31
This module contains common code shared by AuthCookie for Apache 2.x and Apache 2.4.
This method is one you'll use in a server config file (httpd.conf, .htaccess, ...) as a PerlAuthenHandler. If the user provided a session key in a cookie, the authen_ses_key() method will get called to check whether the key is valid. If not, or if there is no key provided, we redirect to the login form.
authen_ses_key()
Return the name of the auth cookie for this request. This is either ${auth_name}CookieName, or AuthCookie's self generated name.
${auth_name}CookieName
Generate a cookie string. %args are:
%args
request
The Apache request object
key
The Cookie name
value
the Cookie value
expires (optional)
When the cookie expires. See "expires()" in Apache::AuthCookie::Util. Uses ${auth_name}Expires if not giv
${auth_name}Expires
All other cookie settings come from PerlSetVar settings.
PerlSetVar
This method returns the $r->requires array, with the requirement values decoded if ${auth_name}RequiresEncoding is in effect for this request.
$r->requires
requirement
${auth_name}RequiresEncoding
If you have set ${auth_name}Encoding, then this will return the decoded value of $r->user.
$r->user
Return the ${auth_name}Encoding setting that is in effect for this request.
Escape the given string so it is suitable to be used in a URL.
Returns the value of PerlSetVar ${auth_name}Path.
PerlSetVar ${auth_name}Path
If ${auth_name}Cache is defined, this sets up the response so that the client will not cache the result. This sents no_cache in the apache request object and sends the appropriate headers so that the client will not cache the response.
${auth_name}Cache
no_cache
This method will return the current session key, if any. This can be handy inside a method that implements a require directive check (like the species method discussed above) if you put any extra information like clearances or whatever into the session key.
require
species
This method handles the submission of the login form. It will call the authen_cred() method, passing it $r and all the submitted data with names like credential_#, where # is a number. These will be passed in a simple array, so the prototype is $self->authen_cred($r, @credentials). After calling authen_cred(), we set the user's cookie and redirect to the URL contained in the destination submitted form field.
authen_cred()
$r
credential_#
$self->authen_cred($r, @credentials)
destination
This method is responsible for displaying the login form. The default implementation will make an internal redirect and display the URL you specified with the PerlSetVar WhatEverLoginScript configuration directive. You can overwrite this method to provide your own mechanism.
PerlSetVar WhatEverLoginScript
This method returns the HTTP status code that will be returned with the login form response. The default behaviour is to return HTTP_FORBIDDEN, except for some known browsers which ignore HTML content for HTTP_FORBIDDEN responses (e.g.: SymbianOS). You can override this method to return custom codes.
Note that HTTP_FORBIDDEN is the most correct code to return as the given request was not authorized to view the requested page. You should only change this if HTTP_FORBIDDEN does not work.
This is simply a convenience method that unsets the session key for you. You can call it in your logout scripts. Usually this looks like $r->auth_type->logout($r).
$r->auth_type->logout($r)
Get the GET/POST params object for this request.
If the user has provided a valid session key but the document isn't protected, this method will set $r->user anyway. Use it as a PerlFixupHandler, unless you have a better idea.
Adds a Set-Cookie header that instructs the client to delete the cookie immediately.
Set-Cookie
Return the ${auth_name}RequiresEncoding setting that is in effect for this request.
By default this method simply sends out the session key you give it. If you need to change the default behavior (perhaps to update a timestamp in the key) you can override this method.
Set a P3P response header if ${auth_name}P3P is configured. The value of the header is whatever is in the ${auth_name}P3P setting.
${auth_name}P3P
This method returns a modified version of the destination parameter before embedding it into the response header. Per default it escapes CR, LF and TAB characters of the uri to avoid certain types of security attacks. You can override it to more limit the allowed destinations, e.g., only allow relative uris, only special hosts or only limited set of characters.
The development version is on github at https://https://github.com/mschout/apache-authcookie and may be cloned from git://https://github.com/mschout/apache-authcookie.git
Please report any bugs or feature requests on the bugtracker website https://github.com/mschout/apache-authcookie/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Michael Schout <mschout@cpan.org>
This software is copyright (c) 2000 by Ken Williams.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Apache::AuthCookie, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::AuthCookie
CPAN shell
perl -MCPAN -e shell install Apache::AuthCookie
For more information on module installation, please visit the detailed CPAN module installation guide.