Apache-AppSamurai
view release on metacpan or search on metacpan
lib/Apache/AppSamurai/Tracker.pm view on Meta::CPAN
}
$self->{object_store} = new $store $self;
$self->{lock_manager} = new $lock $self;
$self->{serialize} = $incl->{$ser}->[0];
$self->{unserialize} = $incl->{$ser}->[1];
# Generate is not used! A fixed ID needs to be passed in at all times
$self->{generate} = \&generate;
# Basic sanity check on passed in ID
$self->{validate} = \&validate;
return $self;
}
# Just plug the static "Name" value from the config in
sub generate {
my $session = shift;
if ($session->{args}->{Name}) {
$session->{data}->{_session_id} = $session->{args}->{Name};
} else {
die "$session - Must pass in Name value! (No generator functionality supported)";
}
}
# Just make sure it looks non-threatening
sub validate {
my $session = shift;
unless ($session->{data}->{_session_id} =~ /^([\w\d\_\-\.]+)$/) {
die "Invalid ID value";
}
return $1;
}
1; # End of Apache::AppSamurai::Tracker
__END__
=head1 NAME
Apache::AppSamurai::Tracker - Apache::AppSamurai scratch-pad/tracking storage
=head1 SYNOPSIS
use Apache::AppSamurai::Tracker;
tie %hash, 'Apache::AppSamurai::Tracker', $id, {
Store => 'Apache::Session::Store::DB_File',
Lock => 'Null',
};
# Postgress backend with session ID passed in directly
# and Baes64 encoding
tie %hash, 'Apache::AppSamurai::Tracker', $id, {
Store => 'Apache::Session::Store::Postgres',
Lock => 'Null',
};
# you decide!
=head1 DESCRIPTION
This module is a subclass of L<Apache::Session|Apache::Session> that can
be used to share non-sensitive information between multiple Apache server
processes. Its main use is to provide storage of IP login failures and other
non-session data for L<Apache::AppSamurai|Apache::AppSamurai>.
The normal Apache::Session C<Generate> option is not used. Each tracker
uses a set session ID. For instance, "IPFailures" is used for the IP failure
tracking feature in Apache::AppSamurai.
The Apache::Session C<Serialize> type is hard set to Base64. This allows
for storage in files or inside a database.
The C<Store> and C<Lock> options are still used and relevant, as are any
configuration options for the specific sub-modules that are used.
=head1 USAGE
You pass the modules you want to use as arguments to the constructor. For
normal Apache::Session sub modules, the Apache::Session::Whatever part is
appended for you: you should not supply it. (Apache::AppSamurai::Tracker
supports the same extended module syntax as
L<Apache::AppSamurai::Session|Apache::AppSamurai::Session>,
though in most cases, the standard Apache::Sesssion types should suffice.)
For example, if you wanted to use MySQL as the backing store, you should give
the argument C<Store => 'MySQL'>, and not
C<Store => 'Apache::Session::Store::MySQL'>. There are two modules that you
need to specify. Store is the backing store to use. Lock is the locking
scheme.
There are many modules included in the Apache::Session distribution that can
be used directly with this module.
Please see L<Apache::Session> for more information.
=head1 SEE ALSO
L<Apache::AppSamurai>, L<Apache::AppSamurai::Session>,
L<Apache::Session>
=head1 AUTHOR
Paul M. Hirsch, C<< <paul at voltagenoir.org> >>
=head1 BUGS
See L<Apache::AppSamurai> for information on bug submission and tracking.
=head1 SUPPORT
See L<Apache::AppSamurai> for support information.
=head1 ACKNOWLEDGEMENTS
This module is based partially on code written by
Jeffrey William Baker <jwbaker@acm.org> and the Apache::Session
authors.
( run in 1.840 second using v1.01-cache-2.11-cpan-39bf76dae61 )