++ed by:
1 non-PAUSE user
Author image Michael Schout

NAME

Apache2::AuthCookie::Base - Common Methods Shared by Apache2 and Apache2_4 AuthCookie Subclasses.

VERSION

version 3.30

DESCRIPTION

This module contains common code shared by AuthCookie for Apache 2.x and Apache 2.4.

METHODS

authenticate($r): int

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.

Return the name of the auth cookie for this request. This is either ${auth_name}CookieName, or AuthCookie's self generated name.

Generate a cookie string. %args are:

  • 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

All other cookie settings come from PerlSetVar settings.

decoded_requires($r): arrayref

This method returns the $r->requires array, with the requirement values decoded if ${auth_name}RequiresEncoding is in effect for this request.

decoded_user($r): string

If you have set ${auth_name}Encoding, then this will return the decoded value of $r->user.

encoding($r): string

Return the ${auth_name}Encoding setting that is in effect for this request.

escape_uri($r, $value): string

Escape the given string so it is suitable to be used in a URL.

Returns the value of PerlSetVar ${auth_name}Path.

handle_cache($r): void

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.

key($r): string

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.

login($r): int

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.

login_form($r): int

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.

login_form_status($r): int

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.

logout($r): void

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

params($r): Apache2::AuthCookie::Params

Get the GET/POST params object for this request.

recognize_user($r): int

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.

remove_cookie($r): void

Adds a Set-Cookie header that instructs the client to delete the cookie immediately.

requires_encoding($r): string

Return the ${auth_name}RequiresEncoding setting that is in effect for this request.

send_cookie($r, $ses_key, $args): void

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.

send_p3p($r): void

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.

untaint_destination($destination): string

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.

SOURCE

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

BUGS

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.

AUTHOR

Michael Schout <mschout@cpan.org>

COPYRIGHT AND LICENSE

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.