line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Session::Store::PSGI; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Catalyst::Plugin::Session::Store::PSGI::VERSION = '0.0.2'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Catalyst::Plugin::Session::Store::PSGI::DIST = 'Catalyst-Plugin-Session-PSGI'; |
7
|
|
|
|
|
|
|
} |
8
|
1
|
|
|
1
|
|
1722
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
9
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Catalyst::Plugin::Session::PSGI; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use base qw/Catalyst::Plugin::Session::Store/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1714
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get_session_data { |
20
|
0
|
|
|
0
|
1
|
|
my ($c, $id) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# grab the PSGI environment |
23
|
0
|
|
|
|
|
|
my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c); |
24
|
|
|
|
|
|
|
return |
25
|
0
|
0
|
|
|
|
|
unless defined $psgi_env; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# TODO: work out correct place to initialise this |
28
|
0
|
|
0
|
|
|
|
$psgi_env->{'psgix.session.expires'} |
29
|
|
|
|
|
|
|
||= $c->get_session_expires; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# grab the relevant data from the PSGI environment |
32
|
0
|
|
|
|
|
|
my $data = $psgi_env->{_psgi_section($id)}; |
33
|
0
|
0
|
|
|
|
|
return $data if $data; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# no session retrieved - hope this isn't too painful |
36
|
0
|
|
|
|
|
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub store_session_data { |
40
|
0
|
|
|
0
|
1
|
|
my ($c, $id, $data) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# grab the PSGI environment |
43
|
0
|
|
|
|
|
|
my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c); |
44
|
|
|
|
|
|
|
return |
45
|
0
|
0
|
|
|
|
|
unless defined $psgi_env; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# grab the relevant data from the PSGI environment |
48
|
0
|
|
|
|
|
|
$psgi_env->{_psgi_section($id)} = $data; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
sub delete_session_data { } # unsupported |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
|
sub delete_expired_sessions { } # unsupported |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _psgi_section { |
56
|
0
|
|
|
0
|
|
|
my $id = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# default to using 'psgi.session' |
59
|
0
|
|
|
|
|
|
my $psgi_section = 'psgix.session'; |
60
|
|
|
|
|
|
|
# add supposert for things like expire: and flash: |
61
|
0
|
0
|
|
|
|
|
if (my ($section, $sid) = ($id =~ m{\A(\w+):(\w+)\z})) { |
62
|
0
|
0
|
|
|
|
|
if ('session' ne $section) { |
63
|
0
|
|
|
|
|
|
$psgi_section .= ".${section}"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $psgi_section; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
# ABSTRACT: Session plugin for access to PSGI/Plack session |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=pod |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Catalyst::Plugin::Session::Store::PSGI - Session plugin for access to PSGI/Plack session |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 0.0.2 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
use Catalyst qw/ |
86
|
|
|
|
|
|
|
Session |
87
|
|
|
|
|
|
|
Session::State::PSGI |
88
|
|
|
|
|
|
|
Session::Store::PSGI |
89
|
|
|
|
|
|
|
/; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
An alternative session storage plugin that allows sharing of the PSGI/Plack session information. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 EXPERIMENTAL |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This distribution should be considered B<experimental>. Although functional, it |
98
|
|
|
|
|
|
|
may break in currently undiscovered use cases. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The plugin provides the following methods: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 get_session_data |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 store_session_data |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 delete_session_data |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This method is NOOP - session data should be deleted by L<Plack::Middleware::Session> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 delete_expired_sessions |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This method is NOOP - sessions should be expired by L<Plack::Middleware::Session> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Chisel <chisel@chizography.net> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Chisel Wright. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
__END__ |
130
|
|
|
|
|
|
|
# vim: ts=8 sts=4 et sw=4 sr sta |