line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Prancer::Session::Store::YAML; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2588
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
109
|
|
4
|
4
|
|
|
4
|
|
10
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
85
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
738
|
use Plack::Session::Store::File; |
|
4
|
|
|
|
|
1476
|
|
|
4
|
|
|
|
|
96
|
|
7
|
4
|
|
|
4
|
|
12
|
use parent qw(Plack::Session::Store::File); |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
143
|
use Carp; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
233
|
|
10
|
4
|
|
|
4
|
|
13
|
use Cwd (); |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
65
|
|
11
|
4
|
|
|
4
|
|
1076
|
use YAML (); |
|
4
|
|
|
|
|
17295
|
|
|
4
|
|
|
|
|
100
|
|
12
|
4
|
|
|
4
|
|
16
|
use Prancer qw(logger); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
967
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
1
|
|
my ($class, $config) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return try { |
18
|
0
|
|
0
|
|
|
|
my $path = Cwd::realpath(delete($config->{'path'}) || '/tmp'); |
19
|
0
|
0
|
|
|
|
|
die "${path} does not exist\n" unless (-e $path); |
20
|
0
|
0
|
|
|
|
|
die "${path} is not readable\n" unless (-r $path); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$config->{'dir'} = $path; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
my $self = bless($class->SUPER::new(%{$config || {}}), $class); |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
|
|
$self->{'_serializer'} = sub { YAML::DumpFile(reverse(@_)) }; |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
|
|
$self->{'_deserializer'} = sub { YAML::LoadFile(@_) }; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
logger->info("intialized session handler with YAML in ${path}"); |
33
|
0
|
|
|
|
|
|
return $self; |
34
|
0
|
|
|
|
|
|
} catch { |
35
|
0
|
0
|
|
|
|
|
my $error = (defined($_) ? $_ : "unknown"); |
36
|
0
|
|
|
|
|
|
logger->fatal("could not initialize sessions handler: ${error}"); |
37
|
0
|
|
|
|
|
|
croak; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Prancer::Session::Store::YAML |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This module implements a session handler based on YAML files. Sessions are |
50
|
|
|
|
|
|
|
stored at the configured path. This backend an perfectly be used in production |
51
|
|
|
|
|
|
|
environments, but two things should be kept in mind: The content of the session |
52
|
|
|
|
|
|
|
files is in plain text, and the session files should be purged by a cron job. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
To use this session handler, add this to your configuration file: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
session: |
57
|
|
|
|
|
|
|
store: |
58
|
|
|
|
|
|
|
driver: Prancer::Session::Store::YAML |
59
|
|
|
|
|
|
|
options: |
60
|
|
|
|
|
|
|
path: /tmp/prancer/sessions |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 OPTIONS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item path |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
B<REQUIRED> This indicates where sessions will be stored. If this path does not |
69
|
|
|
|
|
|
|
exist it will be created, if possible. This must be an absolute path and the |
70
|
|
|
|
|
|
|
destination must be writable by the same user that is running the application |
71
|
|
|
|
|
|
|
server. If this is not set your application will not start. If this is set to a |
72
|
|
|
|
|
|
|
path that your application cannot write to your application will not start. If |
73
|
|
|
|
|
|
|
this is set to a path that doesn't exist and the path can't be created your |
74
|
|
|
|
|
|
|
application will not start. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|