AxKit-XSP-BasicSession
view release on metacpan or search on metacpan
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: AxKit-XSP-BasicSession
version: 0.22
version_from: lib/AxKit/XSP/BasicSession.pm
installdirs: site
requires:
Apache::AuthCookie: 0
Apache::AxKit::Language::XSP::TaglibHelper: 0
Apache::Cookie: 0
Apache::Session::Flex: 0
AxKit: 1.6
Date::Format: 0
Digest::MD5: 0
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'AxKit::XSP::BasicSession',
'VERSION_FROM' => 'lib/AxKit/XSP/BasicSession.pm',
'PREREQ_PM' => {
AxKit => 1.6,
Apache::Session::Flex => 0,
Apache::AxKit::Language::XSP::TaglibHelper => 0,
Date::Format => 0,
Apache::Cookie => 0,
Apache::AuthCookie => 0,
Digest::MD5 => 0,
},
);
lib/Apache/AxKit/Plugin/AddXSLParams/BasicSession.pm view on Meta::CPAN
package Apache::AxKit::Plugin::AddXSLParams::BasicSession;
# $Id: BasicSession.pm,v 1.5 2004/09/17 02:05:22 kjetil Exp $
use strict;
use Apache::Constants;
use Apache::Cookie;
use Apache::Request;
use Apache::URI;
use vars qw($VERSION);
$VERSION = '0.20';
sub handler {
my $r = shift;
my $uri = $r->uri;
my $cgi = Apache::Request->instance($r);
lib/Apache/AxKit/Plugin/BasicAuth.pm view on Meta::CPAN
package Apache::AxKit::Plugin::BasicAuth;
# $Id: BasicAuth.pm,v 1.3 2004/08/19 22:31:21 nachbaur Exp $
use strict;
use Apache;
use Apache::Constants qw(:common M_GET);
use Apache::AuthCookie;
use Apache::Session::Flex;
use Apache::Util qw(escape_uri);
use Digest::MD5 qw(md5_hex);
use vars qw($VERSION);
use base qw(Apache::AuthCookie);
use constant IN_PROGRESS => 1;
$VERSION = 0.19;
sub authen_cred {
my $self = shift;
my $r = shift;
my @creds = @_;
lib/Apache/AxKit/Plugin/BasicAuth.pm view on Meta::CPAN
my $session = shift;
foreach(keys %{$session}) {
delete $session->{$_} if(/^credential_\d+/);
}
}
sub custom_errors {
my ($auth_type, $r, $auth_user, @args) = @_;
$r->subprocess_env('AuthCookieReason', 'bad_cookie');
# They aren't authenticated, and they tried to get a protected
# document. Send them the authen form.
return $auth_type->login_form;
}
# This function disabled since we rely on session management for cookie setting.
sub send_cookie { }
1;
lib/Apache/AxKit/Plugin/BasicSession.pm view on Meta::CPAN
package Apache::AxKit::Plugin::BasicSession;
# $Id: BasicSession.pm,v 1.14 2004/09/16 23:20:43 nachbaur Exp $
use Apache::Session::Flex;
use Apache::Request;
use Apache::Cookie;
use Apache::AuthCookie;
use AxKit;
use vars qw( $VERSION %session );
$VERSION = 0.22;
sub handler
{
my $r = Apache::Request->instance(shift);
# Session handling code
lib/Apache/AxKit/Plugin/BasicSession.pm view on Meta::CPAN
my ($key, $value) = split( /\s*=>\s*/, $arg );
$flex_options{$key} = $value;
}
my $sessionid = undef;
if (defined $uri_token and length($uri_token) > 0) {
$sessionid = $r->param($uri_token);
}
my $cookie_exists = 0;
my $cookie_name = $r->dir_config($prefix . 'Cookie') ? $r->dir_config($prefix . 'Cookie') : 'SID';
unless (defined $sessionid) {
#
# Read in the cookie if this is an old session, using this realm's name as part
# of the cookie
my $cookie = $r->header_in('Cookie');
#my ($auth_type, $auth_name) = ($r->auth_type, $r->auth_name);
($sessionid) = $cookie =~ /$cookie_name=(\w*)/;
$cookie_exists = defined($sessionid) ? 1 : 0;
}
#
# Attempt to load the session from our back-end datastore
eval { tie %session, 'Apache::Session::Flex', $sessionid, \%flex_options }
if ($sessionid and $sessionid ne '');
unless ( $session{_session_id} ) {
AxKit::Debug(6, "Creating a new session, since \"$session{_session_id}\" didn't work.");
eval { tie %session, 'Apache::Session::Flex', undef, \%flex_options };
die "Problem creating session: $@" if $@;
$no_cookie = 1;
}
# Might be a new session, so lets give them a cookie
my $current_time = time;
if (!$cookie_exists or $no_cookie) {
#Apache::AuthCookie->send_cookie($session{_session_id});
my %cookie_args = ();
$cookie_args{'-name'} = $cookie_name;
$cookie_args{'-value'} = $session{_session_id};
$cookie_args{'-expires'} = $r->dir_config($prefix . 'CookieExpires');
$cookie_args{'-domain'} = $r->dir_config($prefix . 'CookieDomain');
$cookie_args{'-path'} = $r->dir_config($prefix . 'CookiePath');
Apache::Cookie->new($r, %cookie_args)->bake;
$session{_creation_time} = $current_time;
AxKit::Debug(9, "Set a new header for the session cookie: \"$session_cookie\"");
}
# Update the "Last Accessed" timestamp key
$session{_last_accessed_time} = $current_time;
AxKit::Debug(9, "Successfully set the session object in the pnotes table");
lib/Apache/AxKit/Plugin/BasicSession.pm view on Meta::CPAN
While BasicSession defaults to using a cookie for sessions, there are times
(e.g. when performing C<document()> lookups within XSLT stylesheets) when it
is not possible to supply the proper cookie information with an HTTP request.
Therefore, you can use this configuration variable to set the name of a
query parameter where the session ID can be found. This is not required, but
will be used in preference to a cookie if this query parameter is supplied.
Note, however, that the W3C recommends against using this for external requests.
=head2 C<BasicSessionCookie*>
These arguments set the parameters your session cookie will be created
with. These are named similarly to the above parameters, namely the prefix
should reflect your local realm name (or "BasicSession" if you aren't doing
authentication). A common thing one might want to set is the expirytime of the session cookie. This can be set using the formats described in L<CGI::Cookie>, e.g.:
PerlSetVar BasicSessionCookieExpires +2d
will make the cookie expire two days from now.
For more information, please see L<Apache::AuthCookie>.
=head2 C<AxKit::XSP::BasicSession Support>
This plugin was created to complement AxKit::XSP::BasicSession, but can be used
without the taglib.
Every session access, the session key "_last_accessed_time" is set to the current
date-timestamp. When a new session is created, the session key "_creation_time" is
set to the current date-timestamp.
lib/AxKit/XSP/BasicAuth.pm view on Meta::CPAN
AxAddPlugin Apache::AxKit::Plugin::BasicSession
AxAddPlugin Apache::AxKit::Plugin::AddXSLParams::BasicSession
# Authentication
PerlSetVar BasicSessionLoginScript /login
=head1 DESCRIPTION
This taglib provides simple form-and-cookie based authentication using
Apache::Session and Apache::AuthCookie.
In the tag reference below, AuthNameToken designates the name given
for AuthName.
=head1 Tag Reference
=head2 C<E<lt>auth:loginE<gt>>
Attempt to log the user in.
( run in 0.368 second using v1.01-cache-2.11-cpan-e9199f4ba4c )