line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Session::State; |
2
|
15
|
|
|
15
|
|
237705
|
use strict; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
341
|
|
3
|
15
|
|
|
15
|
|
63
|
use warnings; |
|
15
|
|
|
|
|
22
|
|
|
15
|
|
|
|
|
538
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.33'; |
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
5551
|
use Digest::SHA (); |
|
15
|
|
|
|
|
34273
|
|
|
15
|
|
|
|
|
366
|
|
9
|
|
|
|
|
|
|
|
10
|
15
|
|
|
15
|
|
2764
|
use Plack::Request; |
|
15
|
|
|
|
|
344336
|
|
|
15
|
|
|
|
|
453
|
|
11
|
15
|
|
|
|
|
109
|
use Plack::Util::Accessor qw[ |
12
|
|
|
|
|
|
|
session_key |
13
|
|
|
|
|
|
|
sid_generator |
14
|
|
|
|
|
|
|
sid_validator |
15
|
15
|
|
|
15
|
|
1752
|
]; |
|
15
|
|
|
|
|
1120
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
14
|
|
|
14
|
1
|
166
|
my ($class, %params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
14
|
|
50
|
|
|
94
|
$params{'session_key'} ||= 'plack_session'; |
21
|
|
|
|
|
|
|
$params{'sid_generator'} ||= sub { |
22
|
36
|
|
|
36
|
|
911
|
Digest::SHA::sha1_hex(rand() . $$ . {} . time) |
23
|
14
|
|
50
|
|
|
97
|
}; |
24
|
14
|
|
33
|
|
|
129
|
$params{'sid_validator'} ||= qr/\A[0-9a-f]{40}\Z/; |
25
|
|
|
|
|
|
|
|
26
|
14
|
|
|
|
|
135
|
bless { %params } => $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub expire_session_id { |
30
|
6
|
|
|
6
|
1
|
55
|
my ($self, $id, $res) = @_; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub validate_session_id { |
34
|
58
|
|
|
58
|
1
|
107
|
my ($self, $id) = @_; |
35
|
58
|
|
|
|
|
201
|
$id =~ $self->sid_validator; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_session_id { |
39
|
54
|
|
|
54
|
1
|
84
|
my ($self, $env) = @_; |
40
|
54
|
|
|
|
|
243
|
return Plack::Request->new($env)->param( $self->session_key ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub extract { |
44
|
78
|
|
|
78
|
1
|
365
|
my ($self, $env) = @_; |
45
|
|
|
|
|
|
|
|
46
|
78
|
|
|
|
|
165
|
my $id = $self->get_session_id( $env ); |
47
|
78
|
100
|
|
|
|
7734
|
return unless defined $id; |
48
|
|
|
|
|
|
|
|
49
|
58
|
100
|
|
|
|
154
|
return $id if $self->validate_session_id( $id ); |
50
|
8
|
|
|
|
|
69
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub generate { |
54
|
36
|
|
|
36
|
1
|
152
|
my $self = shift; |
55
|
36
|
|
|
|
|
113
|
$self->sid_generator->( @_ ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub finalize { |
60
|
48
|
|
|
48
|
1
|
248
|
my ($self, $id, $res, $options) = @_; |
61
|
48
|
|
|
|
|
136
|
(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |