Apache-SessionX
view release on metacpan or search on metacpan
SessionX.pm view on Meta::CPAN
}
$self->{initial_session_id} ||= $session_id ;
if (defined $session_id && $session_id)
{
#check the session ID for remote exploitation attempts
#this will die() on suspicious session IDs.
#eval { &{$self->{validate}}($self); } ;
&{$self->{validate}}($self);
#if (!$@)
{ # session id is ok
$self->{status} &= ($self->{status} ^ NEW);
if ($self -> {'args'}{'create_unknown'})
{
eval { $self -> restore } ;
#warn "Try to load session: $@" if ($@) ;
$@ = "" ;
SessionX.pm view on Meta::CPAN
return new {$self -> {'args'}{'object_store'}} $self;
}
sub get_lock_manager {
my $self = shift;
return new {$self -> {'args'}{'lock_manager'}} $self;
}
#
# Default validate for Apache::Session < 1.53
#
sub validate {
#This routine checks to ensure that the session ID is in the form
#we expect. This must be called before we start diddling around
#in the database or the disk.
my $session = shift;
if ($session->{data}->{_session_id} !~ /^[a-fA-F0-9]+$/) {
die 'Invalid session id' ;
}
}
SessionX.pm view on Meta::CPAN
my $lock = $self->{args}->{Lock};
if (!$self->{populated})
{
my $gen = $self->{args}->{Generate};
my $ser = $self->{args}->{Serialize};
$self->{object_store} = new $store $self if ($store) ;
$self->{lock_manager} = new $lock $self if ($lock);
$self->{generate} = \&{$gen . '::generate'} if ($gen);
$self->{'validate'} = \&{$gen . '::validate'} if ($gen && defined (&{$gen . '::validate'}));
$self->{serialize} = \&{$ser . '::serialize'} if ($ser);
$self->{unserialize} = \&{$ser . '::unserialize'} if ($ser) ;
if (!defined ($self->{'validate'}))
{
$self->{'validate'} = \&validate ;
}
$self->{populated} = 1 ;
}
else
{ # recreate only store & lock classes as far as necessary
$self->{object_store} ||= new $store $self if ($store) ;
$self->{lock_manager} ||= new $lock $self if ($lock);
}
return $self;
SessionX/Generate/MD5.pm view on Meta::CPAN
if (exists $session->{args}->{IDLength}) {
$length = $session->{args}->{IDLength};
}
$session->{data}->{_session_id} =
substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex($arg || (time(). {}. rand(). $$))), 0, $length);
}
sub validate {
#This routine checks to ensure that the session ID is in the form
#we expect. This must be called before we start diddling around
#in the database or the disk.
my $session = shift;
if ($session->{data}->{_session_id} !~ /^[a-fA-F0-9]+$/) {
die 'Invalid session id' ;
}
}
( run in 0.537 second using v1.01-cache-2.11-cpan-a5abf4f5562 )