| 1 | package YATT::Lite::WebMVC0::Partial::Session; | ||||||||||||||||||||||||||||
| 2 | sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use YATT::Lite::Partial | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | (requires => [qw/error | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | app_path_ensure_existing | ||||||||||||||||||||||||||||
| 10 | app_path_var_tmp | ||||||||||||||||||||||||||||
| 11 | /] | ||||||||||||||||||||||||||||
| 12 | , fields => [qw/session_driver | ||||||||||||||||||||||||||||
| 13 | session_config | ||||||||||||||||||||||||||||
| 14 | session_debug | ||||||||||||||||||||||||||||
| 15 | session_path | ||||||||||||||||||||||||||||
| 16 | csrftok_name | ||||||||||||||||||||||||||||
| 17 | tmpdir | ||||||||||||||||||||||||||||
| 18 | /] | ||||||||||||||||||||||||||||
| 19 | , -Entity, -CON | ||||||||||||||||||||||||||||
| 20 | 1 | ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use YATT::Lite::Util qw/lexpand escape nonempty symtab | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | num_is_ge/; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use YATT::Lite::Types [Config => fields => [qw/name expire/]]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | #======================================== | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use YATT::Lite::WebMVC0::Connection; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | sub Connection () {'YATT::Lite::WebMVC0::Connection'} | ||||||||||||||||||||||||||||
| 31 | sub ConnProp () {Connection} | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #======================================== | ||||||||||||||||||||||||||||
| 34 | # Session support, based on CGI::Session. | ||||||||||||||||||||||||||||
| 35 | #======================================== | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | Entity sess => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 38 | 0 | my ($this) = shift; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # This will call MY->session_resume. | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $sess = $CON->get_session | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | or return undef; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | $sess->param(@_); | |||||||||||||||||||||||||||
| 45 | 1 | }; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | Entity csrf_token_input => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 48 | 0 | my ($this, $name) = @_; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | $name ||= $CON->cget('system')->csrftok_name; | ||||||||||||||||||||||||||
|
Condition0%0/3
$name ||= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
MC/DC0%0/2
$name ||= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
$name
$YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
Truth table0%0/3
A ||= B
A= $nameB= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | \ sprintf <<END, $name, escape($CON->get_session_sid); | |||||||||||||||||||||||||||
| 52 | <input type="hidden" name="%s" value="%s"> | ||||||||||||||||||||||||||||
| 53 | END | ||||||||||||||||||||||||||||
| 54 | 1 | }; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | Entity csrf_token_check => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 57 | 0 | my ($this, $name) = @_; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | $name ||= $CON->cget('system')->csrftok_name; | ||||||||||||||||||||||||||
|
Condition0%0/3
$name ||= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
MC/DC0%0/2
$name ||= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
$name
$YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
Truth table0%0/3
A ||= B
A= $nameB= $YATT::Lite::WebMVC0::Partial::Session::CON->cget("system")->csrftok_name
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | nonempty(my $sid = $CON->get_session_sid) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | or return undef; | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | nonempty(my $got = $CON->param($name)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | or return undef; | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $sid eq $got; | |||||||||||||||||||||||||||
| 66 | 1 | }; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 1 | my $symtab = symtab(MY); | |||||||||||||||||||||||||||
| 70 | 1 | foreach my $meth (grep {/^session_/} keys %$symtab) { | |||||||||||||||||||||||||||
| 71 | 11 | my $sub = MY->can($meth); | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | Entity $meth => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 73 | 0 | my $this = shift; | |||||||||||||||||||||||||||
| 74 | 0 | my ConnProp $prop = $CON->prop; | |||||||||||||||||||||||||||
| 75 | 0 | my MY $self = $prop->{system}; | |||||||||||||||||||||||||||
| 76 | 0 | $self->$meth($CON, @_); | |||||||||||||||||||||||||||
| 77 | 11 | }; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | #======================================== | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # This will be called back from $CON->get_session_sid. | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub session_sid { | ||||||||||||||||||||||||||
|
Subroutine
session_sid: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 0 | (my MY $self, my ($con)) = @_; | |||||||||||||||||||||||||||
| 86 | 0 | my ConnProp $prop = $con->prop; | |||||||||||||||||||||||||||
| 87 | 0 | my $sid_name = $self->session_sid_name; | |||||||||||||||||||||||||||
| 88 | 0 | ▶ | my $ck = $con->cookies_in->{$sid_name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | or return undef; | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | ref $ck ? $ck->value : $ck; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub session_regenerate_id { | ||||||||||||||||||||||||||
|
Subroutine
session_regenerate_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | 0 | (my MY $self, my ($con, @with_init)) = @_; | |||||||||||||||||||||||||||
| 95 | 0 | my ConnProp $prop = $con->prop; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (defined $prop->{_session}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $self->session_delete($con); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | $self->session_start($con, @with_init); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # This will be called back from $CON->get_session. | ||||||||||||||||||||||||||||
| 105 | # usually called from before_dirhandler | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub session_resume { | ||||||||||||||||||||||||||
|
Subroutine
session_resume: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | 0 | (my MY $self, my ($con)) = @_; | |||||||||||||||||||||||||||
| 108 | $con->logbacktrace("session.resume") | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if num_is_ge($self->{session_debug}, 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | my ConnProp $prop = $con->prop; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if (exists $prop->{_session}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | $con->logdump("session.resume" => "session is already loaded") | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | return $prop->{_session}; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | 0 | $prop->{_session} = undef; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my $sid = $self->session_sid($con) or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | $con->logdump("session.resume" => "sid is empty") | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | return undef; | |||||||||||||||||||||||||||
| 124 | }; | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $sess = $self->session_create_by(load => $con, $sid) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | or $self->error("Can't load session for sid='%s': %s" | ||||||||||||||||||||||||||||
| 128 | , $sid, CGI::Session->errstr); | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | CHK: { | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ($sess->is_expired) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 132 | $con->logdump("session.resume" => expired => $sid) | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | } elsif (not $sess->id) { | ||||||||||||||||||||||||||||
| 135 | $con->logdump("session.resume" => "id is empty" | ||||||||||||||||||||||||||||
| 136 | , claimed_sid => $sid, sessobj => $sess) | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||
| 139 | 0 | last CHK; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | # not ok. | ||||||||||||||||||||||||||||
| 142 | 0 | delete $prop->{_session}; # To allow calling session_start. | |||||||||||||||||||||||||||
| 143 | 0 | return undef; # XXX: Should we notify? | |||||||||||||||||||||||||||
| 144 | }; | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | $con->logdump("session.resume" => OK => sid => $sid) | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | $prop->{_session} = $sess; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # This will be called back from $CON->start_session. | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub session_start { | ||||||||||||||||||||||||||
|
Subroutine
session_start: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 154 | 0 | (my MY $self, my ($con, @with_init)) = @_; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $opts = shift @with_init if @with_init and ref $with_init[0] eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@with_init and ref $with_init[0] eq "HASH"
MC/DC0%0/2
@with_init and ref $with_init[0] eq "HASH"
@with_init
ref $with_init[0] eq "HASH"
Truth table0%0/3
A and B
A= @with_initB= ref $with_init[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my $path = delete $opts->{path} || $self->session_path($con); | ||||||||||||||||||||||||||
|
Condition0%0/3
delete $opts->{'path'} || $self->session_path($con)
MC/DC0%0/2
delete $opts->{'path'} || $self->session_path($con)
delete $opts->{'path'}
$self->session_path($con)
Truth table0%0/3
A || B
A= delete $opts->{'path'}B= $self->session_path($con)
| |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if (keys %$opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | $self->error("Invalid option for session_start: %s" | |||||||||||||||||||||||||||
| 160 | , join ", ", keys %$opts); | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | $con->logbacktrace("session.start") | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if num_is_ge($self->{session_debug}, 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | my ConnProp $prop = $con->prop; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (defined $prop->{_session}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | $self->error("session is called twice! sid=%s", $prop->{_session}->id); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 0 | $prop->{_session} = undef; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $sess = $self->session_create_by(new => $con) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | or $self->error("Can't create new session: %s", CGI::Session->errstr); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | $con->set_cookie($self->session_sid_name | |||||||||||||||||||||||||||
| 177 | , $sess->id | ||||||||||||||||||||||||||||
| 178 | , -path => $path); | ||||||||||||||||||||||||||||
| 179 | 0 | $sess->clear; | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | $self->session_init($con, $sess, @with_init) if @with_init; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | $prop->{_session} = $sess; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub session_create_by { | ||||||||||||||||||||||||||
|
Subroutine
session_create_by: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 186 | 0 | (my MY $self, my ($method, $con, $sid)) = @_; | |||||||||||||||||||||||||||
| 187 | 0 | require CGI::Session; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | my ($type, %driver_opts) = $self->session_driver; | |||||||||||||||||||||||||||
| 190 | 0 | my Config $opts = $self->{session_config}; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $expire = delete($opts->{expire}) // $self->default_session_expire; | ||||||||||||||||||||||||||
|
Condition0%0/3
delete $opts->{"expire"} // $self->default_session_expire
MC/DC0%0/2
delete $opts->{"expire"} // $self->default_session_expire
delete $opts->{"expire"}
$self->default_session_expire
Truth table0%0/3
A // B
A= delete $opts->{"expire"}B= $self->default_session_expire
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if (my $sess = CGI::Session->$method($type, $sid, \%driver_opts, $opts)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | unless ($sess->is_expired) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $sess->expire($expire); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | 0 | return $sess; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub session_init { | ||||||||||||||||||||||||||
|
Subroutine
session_init: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 202 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||
| 203 | 0 | my ConnProp $prop = (my $con = shift)->prop; | |||||||||||||||||||||||||||
| 204 | 0 | my ($sess, @with_init) = @_; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | foreach my $spec (@with_init) { | |||||||||||||||||||||||||||
| 207 | 0 | ▶ | unless (defined $spec) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 208 | 0 | $self->error("Undefined session initializer"); | |||||||||||||||||||||||||||
| 209 | } elsif (ref $spec eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 210 | 0 | my ($name, @value) = @$spec; | |||||||||||||||||||||||||||
| 211 | 0 | $sess->param($name, @value); | |||||||||||||||||||||||||||
| 212 | ▶ | } elsif (not ref $spec or ref $spec eq 'Regexp') { | |||||||||||||||||||||||||||
|
Condition0%0/3
not ref $spec or ref $spec eq "Regexp"
MC/DC0%0/2
not ref $spec or ref $spec eq "Regexp"
not ref $spec
ref $spec eq "Regexp"
Truth table0%0/3
not(A) or B
A= not ref $specB= ref $spec eq "Regexp"
| |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $spec = qr{^\Q$spec} unless ref $spec; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | foreach my $name ($con->param) { | |||||||||||||||||||||||||||
| 215 | 0 | ▶ | next unless $name =~ $spec; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | my (@value) = $con->param($name); | |||||||||||||||||||||||||||
| 217 | 0 | $sess->param($name, @value); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||
| 220 | 0 | $self->error("Invalid session initializer: %s" | |||||||||||||||||||||||||||
| 221 | , terse_dump($spec)); | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub session_driver { | ||||||||||||||||||||||||||
|
Subroutine
session_driver: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 227 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||
| 228 | $self->{session_driver} | ||||||||||||||||||||||||||||
| 229 | ? lexpand($self->{session_driver}) | ||||||||||||||||||||||||||||
| 230 | 0 | ▶ | : $self->default_session_driver; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub session_delete { | ||||||||||||||||||||||||||
|
Subroutine
session_delete: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 234 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||
| 235 | 0 | my ConnProp $prop = (my $con = shift)->prop; | |||||||||||||||||||||||||||
| 236 | 0 | my $opts = shift; | |||||||||||||||||||||||||||
| 237 | 0 | ▶ | my $path = delete $opts->{path} || $self->session_path($con); | ||||||||||||||||||||||||||
|
Condition0%0/3
delete $opts->{'path'} || $self->session_path($con)
MC/DC0%0/2
delete $opts->{'path'} || $self->session_path($con)
delete $opts->{'path'}
$self->session_path($con)
Truth table0%0/3
A || B
A= delete $opts->{'path'}B= $self->session_path($con)
| |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if (keys %$opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | $self->error("Invalid option for session_delete: %s" | |||||||||||||||||||||||||||
| 240 | , join ", ", keys %$opts); | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | $con->logbacktrace("session.delete") | ||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if num_is_ge($self->{session_debug}, 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if (my $sess = delete $prop->{_session}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | my $sid = $sess->id; | |||||||||||||||||||||||||||
| 248 | 0 | $sess->delete; | |||||||||||||||||||||||||||
| 249 | 0 | $sess->flush; | |||||||||||||||||||||||||||
| 250 | $con->logdump("session.delete" => OK => sid => $sid) | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | } else { | ||||||||||||||||||||||||||||
| 253 | $con->logdump("session.delete" => 'NOP') | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if $self->{session_debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | my $name = $self->session_sid_name; | |||||||||||||||||||||||||||
| 257 | 0 | my @rm = ($name, '', -expires => '-10y', -path => $path); | |||||||||||||||||||||||||||
| 258 | 0 | $con->set_cookie(@rm); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub session_flush { | ||||||||||||||||||||||||||
|
Subroutine
session_flush: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 262 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||
| 263 | 0 | my ConnProp $prop = (my $glob = shift)->prop; | |||||||||||||||||||||||||||
| 264 | my $sess = $prop->{_session} | ||||||||||||||||||||||||||||
| 265 | 0 | ▶ | or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | return if $sess->errstr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 0 | $sess->flush; | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (my $err = $sess->errstr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 0 | local $prop->{_session}; | |||||||||||||||||||||||||||
| 270 | 0 | $self->error("Can't flush session: %s", $err); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | ▶ | sub configure_use_session { | ||||||||||||||||||||||||||
|
Subroutine
configure_use_session: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 275 | 0 | (my MY $self, my $value) = @_; | |||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | $self->{session_config} | ||||||||||||||||||||||||||||
| 278 | 0 | ▶ | //= ref $value ? +{lexpand($value)} : +{$self->default_session_config}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"session_config"} //= ref $value ? {lexpand($value)} : {$self->default_session_config}
MC/DC0%0/2
$self->{"session_config"} //= ref $value ? {lexpand($value)} : {$self->default_session_config}
$self->{"session_config"}
ref $value ? {lexpand($value)} : {$self->default_session_config}
Truth table0%0/3
A //= B
A= $self->{"session_config"}B= ref $value ? {lexpand($value)} : {$self->default_session_config}
| |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $self->{session_driver} //= [$self->default_session_driver]; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"session_driver"} //= [$self->default_session_driver]
MC/DC0%0/1
$self->{"session_driver"} //= [$self->default_session_driver]
$self->{"session_driver"}
Truth table0%0/2
A
A= $self->{"session_driver"}
| |||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub session_path { | ||||||||||||||||||||||||||
|
Subroutine
session_path: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 284 | 0 | (my MY $self, my ($con)) = @_; | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | $self->{session_path} || $con->site_location; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub session_sid_name { | ||||||||||||||||||||||||||
|
Subroutine
session_sid_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 289 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||
| 290 | 0 | my Config $opts = $self->{session_config}; | |||||||||||||||||||||||||||
| 291 | 0 | ▶ | $opts->{name} || $self->default_session_sid_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub default_session_expire { '1d' } | ||||||||||||||||||||||||||
|
Subroutine
default_session_expire: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub default_session_sid_name { 'SID' } | ||||||||||||||||||||||||||
|
Subroutine
default_session_sid_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub default_session_config {} | ||||||||||||||||||||||||||
|
Subroutine
default_session_config: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub default_session_driver { | ||||||||||||||||||||||||||
|
Subroutine
default_session_driver: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 299 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||
| 300 | 0 | ▶ | my $tmpdir = $self->{tmpdir} //= $self->app_path_var_tmp('sess'); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"tmpdir"} //= $self->app_path_var_tmp("sess")
MC/DC0%0/2
$self->{"tmpdir"} //= $self->app_path_var_tmp("sess")
$self->{"tmpdir"}
$self->app_path_var_tmp("sess")
Truth table0%0/3
A //= B
A= $self->{"tmpdir"}B= $self->app_path_var_tmp("sess")
| |||||||||||||||||||||||||||||
| 301 | 0 | ("driver:file" | |||||||||||||||||||||||||||
| 302 | , Directory => $tmpdir | ||||||||||||||||||||||||||||
| 303 | ) | ||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub cmd_session_list { | ||||||||||||||||||||||||||
|
Subroutine
cmd_session_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 307 | 0 | (my MY $self, my @param) = @_; | |||||||||||||||||||||||||||
| 308 | 0 | print join("\t", qw(id created accessed), @param), "\n"; | |||||||||||||||||||||||||||
| 309 | 0 | require CGI::Session; | |||||||||||||||||||||||||||
| 310 | 0 | my ($type, %driver_opts) = $self->session_driver; | |||||||||||||||||||||||||||
| 311 | 0 | ▶ | CGI::Session->find($type, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 312 | 0 | my ($sess) = @_; | |||||||||||||||||||||||||||
| 313 | 0 | ▶ | print join("\t", map {defined $_ ? $_ : "(undef)"} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | $sess->id, $sess->ctime, $sess->atime | ||||||||||||||||||||||||||||
| 315 | 0 | , map {$sess->param($_)} @param), "\n"; | |||||||||||||||||||||||||||
| 316 | 0 | }, \%driver_opts); | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub csrftok_name { | ||||||||||||||||||||||||||
|
Subroutine
csrftok_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 321 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||
| 322 | 0 | ▶ | $self->{csrftok_name} || $self->default_csrftok_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub default_csrftok_name { '--csrftok' } | ||||||||||||||||||||||||||
|
Subroutine
default_csrftok_name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 1 | 1; | |||||||||||||||||||||||||||