| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::Session::State; |
|
2
|
15
|
|
|
15
|
|
564945
|
use strict; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
633
|
|
|
3
|
15
|
|
|
15
|
|
80
|
use warnings; |
|
|
15
|
|
|
|
|
30
|
|
|
|
15
|
|
|
|
|
1140
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.36'; |
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
8256
|
use Crypt::SysRandom (); |
|
|
15
|
|
|
|
|
38340
|
|
|
|
15
|
|
|
|
|
714
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# RECOMMEND PREREQ: Crypt::SysRandom::XS |
|
11
|
|
|
|
|
|
|
|
|
12
|
15
|
|
|
15
|
|
5784
|
use Plack::Request; |
|
|
15
|
|
|
|
|
580097
|
|
|
|
15
|
|
|
|
|
656
|
|
|
13
|
15
|
|
|
|
|
137
|
use Plack::Util::Accessor qw[ |
|
14
|
|
|
|
|
|
|
session_key |
|
15
|
|
|
|
|
|
|
sid_generator |
|
16
|
|
|
|
|
|
|
sid_validator |
|
17
|
15
|
|
|
15
|
|
2847
|
]; |
|
|
15
|
|
|
|
|
2150
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
|
20
|
15
|
|
|
15
|
1
|
300983
|
my ($class, %params) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
15
|
|
50
|
|
|
136
|
$params{'session_key'} ||= 'plack_session'; |
|
23
|
|
|
|
|
|
|
$params{'sid_generator'} ||= sub { |
|
24
|
34
|
|
|
34
|
|
752
|
unpack('H*', Crypt::SysRandom::random_bytes(20)) |
|
25
|
15
|
|
33
|
|
|
173
|
}; |
|
26
|
15
|
|
33
|
|
|
193
|
$params{'sid_validator'} ||= qr/\A[0-9a-f]{40}\Z/; |
|
27
|
|
|
|
|
|
|
|
|
28
|
15
|
|
|
|
|
271
|
bless { %params } => $class; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub expire_session_id { |
|
32
|
6
|
|
|
6
|
1
|
98
|
my ($self, $id, $res) = @_; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub validate_session_id { |
|
36
|
58
|
|
|
58
|
1
|
176
|
my ($self, $id) = @_; |
|
37
|
58
|
|
|
|
|
238
|
$id =~ $self->sid_validator; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_session_id { |
|
41
|
54
|
|
|
54
|
1
|
149
|
my ($self, $env) = @_; |
|
42
|
54
|
|
|
|
|
592
|
return Plack::Request->new($env)->param( $self->session_key ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub extract { |
|
46
|
76
|
|
|
76
|
1
|
550
|
my ($self, $env) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
76
|
|
|
|
|
253
|
my $id = $self->get_session_id( $env ); |
|
49
|
76
|
100
|
|
|
|
27243
|
return unless defined $id; |
|
50
|
|
|
|
|
|
|
|
|
51
|
58
|
100
|
|
|
|
241
|
return $id if $self->validate_session_id( $id ); |
|
52
|
8
|
|
|
|
|
133
|
return; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub generate { |
|
56
|
34
|
|
|
34
|
1
|
226
|
my $self = shift; |
|
57
|
34
|
|
|
|
|
190
|
$self->sid_generator->( @_ ); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub finalize { |
|
62
|
48
|
|
|
48
|
1
|
445
|
my ($self, $id, $res, $options) = @_; |
|
63
|
48
|
|
|
|
|
228
|
(); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |