| 1 | package Catalyst::Plugin::Session; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | with 'MooseX::Emulate::Class::Accessor::Fast'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use MRO::Compat; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Catalyst::Exception (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Crypt::SysRandom (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Object::Signature (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use HTML::Entities (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use List::Util qw/ max /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | our $VERSION = '0.44'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | my @session_data_accessors; # used in delete_session | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | __PACKAGE__->mk_accessors( | |||||||||||||||||||||||||||||||||||||||||
| 22 | "_session_delete_reason", | ||||||||||||||||||||||||||||||||||||||||||
| 23 | @session_data_accessors = qw/ | ||||||||||||||||||||||||||||||||||||||||||
| 24 | _sessionid | ||||||||||||||||||||||||||||||||||||||||||
| 25 | _session | ||||||||||||||||||||||||||||||||||||||||||
| 26 | _session_expires | ||||||||||||||||||||||||||||||||||||||||||
| 27 | _extended_session_expires | ||||||||||||||||||||||||||||||||||||||||||
| 28 | _session_data_sig | ||||||||||||||||||||||||||||||||||||||||||
| 29 | _flash | ||||||||||||||||||||||||||||||||||||||||||
| 30 | _flash_keep_keys | ||||||||||||||||||||||||||||||||||||||||||
| 31 | _flash_key_hashes | ||||||||||||||||||||||||||||||||||||||||||
| 32 | _tried_loading_session_id | ||||||||||||||||||||||||||||||||||||||||||
| 33 | _tried_loading_session_data | ||||||||||||||||||||||||||||||||||||||||||
| 34 | _tried_loading_session_expires | ||||||||||||||||||||||||||||||||||||||||||
| 35 | _tried_loading_flash_data | ||||||||||||||||||||||||||||||||||||||||||
| 36 | _needs_early_session_finalization | ||||||||||||||||||||||||||||||||||||||||||
| 37 | / | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 15 | ▶ | sub _session_plugin_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_session_plugin_config: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 15 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | # FIXME - Start warning once all the state/store modules have also been updated. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | #$c->log->warn("Deprecated 'session' config key used, please use the key 'Plugin::Session' instead") | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # if exists $c->config->{session} | ||||||||||||||||||||||||||||||||||||||||||
| 45 | #$c->config->{'Plugin::Session'} ||= delete($c->config->{session}) || {}; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 15 | ▶ | $c->config->{'Plugin::Session'} ||= $c->config->{session} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$c->config->{"Plugin::Session"} ||= $c->config->{"session"} || {}
$c->config->{'session'} || {}
MC/DC0%0/2
$c->config->{"Plugin::Session"} ||= $c->config->{"session"} || {}
$c->config->{"Plugin::Session"}
$c->config->{'session'}
Truth table33%1/3
A ||= B
A= $c->config->{"Plugin::Session"}B= $c->config->{'session'}
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | sub setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | $c->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | $c->check_session_plugin_requirements; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | $c->setup_session; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | return $c; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | ▶ | sub check_session_plugin_requirements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_session_plugin_requirements: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | ▶ | unless ( $c->isa("Catalyst::Plugin::Session::State") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c->isa("Catalyst::Plugin::Session::State") and $c->isa("Catalyst::Plugin::Session::Store")
MC/DC100%2/2
$c->isa("Catalyst::Plugin::Session::State") and $c->isa("Catalyst::Plugin::Session::Store")
$c->isa("Catalyst::Plugin::Session::State")
$c->isa("Catalyst::Plugin::Session::Store")
Truth table100%3/3
A and B
A= $c->isa("Catalyst::Plugin::Session::State")B= $c->isa("Catalyst::Plugin::Session::Store")
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | && $c->isa("Catalyst::Plugin::Session::Store") ) | ||||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my $err = | |||||||||||||||||||||||||||||||||||||||||
| 67 | ( "The Session plugin requires both Session::State " | ||||||||||||||||||||||||||||||||||||||||||
| 68 | . "and Session::Store plugins to be used as well." ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | $c->log->fatal($err); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | Catalyst::Exception->throw($err); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | sub setup_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | my $cfg = $c->_session_plugin_config; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | %$cfg = ( | |||||||||||||||||||||||||||||||||||||||||
| 81 | expires => 7200, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | verify_address => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | verify_user_agent => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | expiry_threshold => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | %$cfg, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | $c->maybe::next::method(); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | sub prepare_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_action: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $c->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | if ( $c->_session_plugin_config->{flash_to_stash} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$c->_session_plugin_config->{"flash_to_stash"} and $c->sessionid and my $flash_data = $c->flash
$c->_session_plugin_config->{"flash_to_stash"} and $c->sessionid
MC/DC0%0/3
$c->_session_plugin_config->{"flash_to_stash"} and $c->sessionid and my $flash_data = $c->flash
$c->_session_plugin_config->{"flash_to_stash"}
$c->sessionid
my $flash_data = $c->flash
Truth table25%1/4
A and B and C
A= $c->_session_plugin_config->{"flash_to_stash"}B= $c->sessionidC= my $flash_data = $c->flash
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | and $c->sessionid | ||||||||||||||||||||||||||||||||||||||||||
| 98 | and my $flash_data = $c->flash ) | ||||||||||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | @{ $c->stash }{ keys %$flash_data } = values %$flash_data; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub finalize_headers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_headers: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # fix cookie before we send headers | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $c->_save_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | # Force extension of session_expires before finalizing headers, so a pos | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # up to date. First call to session_expires will extend the expiry, subs | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # just return the previously extended value. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $c->session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $c->finalize_session if $c->_needs_early_session_finalization; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return $c->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | ▶ | sub finalize_body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_body: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # We have to finalize our session *before* $c->engine->finalize_xxx is called, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | # because we do not want to send the HTTP response before the session is stored/committed to | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # the session database (or whatever Session::Store you use). | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 6 | ▶ | $c->finalize_session unless $c->_needs_early_session_finalization; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 6 | $c->_clear_session_instance_data; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | return $c->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | ▶ | sub finalize_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | $c->maybe::next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | $c->_save_session_id; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | $c->_save_session; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | $c->_save_flash; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 12 | ▶ | sub _session_updated { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_session_updated: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 12 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 12 | ▶ | if ( my $session_data = $c->_session ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 11 | ▶ | if ( Object::Signature::signature($session_data) ne | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | $c->_session_data_sig ) | ||||||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 7 | return $session_data; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | sub _save_session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_session_id: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | # we already called set when allocating | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # no need to tell the state plugins anything new | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub _save_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_session_expires: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ( defined($c->_session_expires) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if (my $sid = $c->sessionid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $current = $c->_get_stored_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $extended = $c->session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($extended > $current) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $c->store_session_data( "expires:$sid" => $extended ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 12 | ▶ | sub _save_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_session: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 12 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | ▶ | if ( my $session_data = $c->_session_updated ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | $session_data->{__updated} = time(); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | my $sid = $c->sessionid; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | $c->store_session_data( "session:$sid" => $session_data ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | ▶ | sub _save_flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_flash: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | if ( my $flash_data = $c->_flash ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | ▶ | my $hashes = $c->_flash_key_hashes || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->_flash_key_hashes || {}
MC/DC100%1/1
$c->_flash_key_hashes || {}
$c->_flash_key_hashes
Truth table100%2/2
A
A= $c->_flash_key_hashes
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | ▶ | my $keep = $c->_flash_keep_keys || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->_flash_keep_keys || {}
MC/DC100%1/1
$c->_flash_keep_keys || {}
$c->_flash_keep_keys
Truth table100%2/2
A
A= $c->_flash_keep_keys
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | foreach my $key ( keys %$hashes ) { | |||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | if ( !exists $keep->{$key} and Object::Signature::signature( \$flash_data->{$key} ) eq $hashes->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $keep->{$key} and Object::Signature::signature(\$flash_data->{$key}) eq $hashes->{$key}
MC/DC0%0/2
not exists $keep->{$key} and Object::Signature::signature(\$flash_data->{$key}) eq $hashes->{$key}
not exists $keep->{$key}
Object::Signature::signature(\$flash_data->{$key}) eq $hashes->{$key}
Truth table33%1/3
not(A) and B
A= not exists $keep->{$key}B= Object::Signature::signature(\$flash_data->{$key}) eq $hashes->{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | delete $flash_data->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 6 | my $sid = $c->sessionid; | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | my $session_data = $c->_session; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 6 | ▶ | if (%$flash_data) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | $session_data->{__flash} = $flash_data; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | delete $session_data->{__flash}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | $c->_session($session_data); | |||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | $c->_save_session; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | ▶ | sub _load_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_session_expires: called CC=4 SCAR=15.5
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 6 | ▶ | return $c->_session_expires if $c->_tried_loading_session_expires; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | $c->_tried_loading_session_expires(1); | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | my $expires = $c->_get_stored_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | ▶ | if ( $expires >= time() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 6 | $c->_session_expires( $expires ); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 6 | return $expires; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $c->delete_session( "session expired" ); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | ▶ | sub _load_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_session: called CC=12 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | ▶ | return $c->_session if $c->_tried_loading_session_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 6 | $c->_tried_loading_session_data(1); | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 6 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | ▶ | if ( $c->_load_session_expires ) { # > 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | my $session_data = $c->get_session_data("session:$sid") || return; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->get_session_data("session:$sid") || (return)
MC/DC0%0/1
$c->get_session_data("session:$sid") || (return)
$c->get_session_data("session:$sid")
Truth table50%1/2
A
A= $c->get_session_data("session:$sid")
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | $c->_session($session_data); | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | ▶ | no warnings 'uninitialized'; # ne __address | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | ▶ | if ( $c->_session_plugin_config->{verify_address} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$c->_session_plugin_config->{"verify_address"} and exists $session_data->{"__address"} and $session_data->{"__address"} ne $c->request->address
$c->_session_plugin_config->{"verify_address"} and exists $session_data->{"__address"}
MC/DC0%0/3
$c->_session_plugin_config->{"verify_address"} and exists $session_data->{"__address"} and $session_data->{"__address"} ne $c->request->address
$c->_session_plugin_config->{"verify_address"}
exists $session_data->{"__address"}
$session_data->{"__address"} ne $c->request->address
Truth table25%1/4
A and B and C
A= $c->_session_plugin_config->{"verify_address"}B= exists $session_data->{"__address"}C= $session_data->{"__address"} ne $c->request->address
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | && exists $session_data->{__address} | ||||||||||||||||||||||||||||||||||||||||||
| 259 | && $session_data->{__address} ne $c->request->address ) | ||||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | $c->log->warn( | ||||||||||||||||||||||||||||||||||||||||||
| 262 | "Deleting session $sid due to address mismatch (" | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | . $session_data->{__address} . " != " | |||||||||||||||||||||||||||||||||||||||||
| 264 | . $c->request->address . ")" | ||||||||||||||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $c->delete_session("address mismatch"); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 6 | ▶ | if ( $c->_session_plugin_config->{verify_user_agent} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$c->_session_plugin_config->{"verify_user_agent"} and $session_data->{"__user_agent"} ne $c->request->user_agent
MC/DC0%0/2
$c->_session_plugin_config->{"verify_user_agent"} and $session_data->{"__user_agent"} ne $c->request->user_agent
$c->_session_plugin_config->{"verify_user_agent"}
$session_data->{"__user_agent"} ne $c->request->user_agent
Truth table33%1/3
A and B
A= $c->_session_plugin_config->{"verify_user_agent"}B= $session_data->{"__user_agent"} ne $c->request->user_agent
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | && $session_data->{__user_agent} ne $c->request->user_agent ) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||||||||||||||
| 272 | $c->log->warn( | ||||||||||||||||||||||||||||||||||||||||||
| 273 | "Deleting session $sid due to user agent mismatch (" | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | . $session_data->{__user_agent} . " != " | |||||||||||||||||||||||||||||||||||||||||
| 275 | . $c->request->user_agent . ")" | ||||||||||||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $c->delete_session("user agent mismatch"); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 6 | ▶ | $c->log->debug(qq/Restored session "$sid"/) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 6 | ▶ | $c->_session_data_sig( Object::Signature::signature($session_data) ) if $session_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | $c->_expire_session_keys; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 6 | return $session_data; | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 6 | ▶ | sub _load_flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_flash: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 6 | ▶ | return $c->_flash if $c->_tried_loading_flash_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | $c->_tried_loading_flash_data(1); | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 6 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 6 | my $session_data = $c->session; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 6 | $c->_flash($session_data->{__flash}); | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | ▶ | if ( my $flash_data = $c->_flash ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $c->_flash_key_hashes({ map { $_ => Object::Signature::signature( \$flash_data->{$_} ) } keys %$flash_data }); | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | return $flash_data; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ▶ | sub _expire_session_keys { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expire_session_keys: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | my ( $c, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 6 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 | ▶ | my $expire_times = ( $data || $c->_session || {} )->{__expire_keys} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
+($data || $c->_session || {})->{'__expire_keys'} || {}
$data || $c->_session || {}
$data or $c->_session
MC/DC0%0/2
+($data || $c->_session || {})->{'__expire_keys'} || {}
$data
$c->_session
Truth table33%1/3
A or B
A= $dataB= $c->_session
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | foreach my $key ( grep { $expire_times->{$_} < $now } keys %$expire_times ) { | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | delete $c->_session->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | delete $expire_times->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | ▶ | sub _clear_session_instance_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear_session_instance_data: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 6 | $c->$_(undef) for @session_data_accessors; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 6 | $c->maybe::next::method(@_); # allow other plugins to hook in on this | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub change_session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_session_id: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $sessiondata = $c->session; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $oldsid = $c->sessionid; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $newsid = $c->create_session_id; | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ($oldsid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $c->log->debug(qq/change_sessid: deleting session data from "$oldsid"/) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $c->delete_session_data("${_}:${oldsid}") for qw/session expires flash/; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | $c->log->debug(qq/change_sessid: storing session data to "$newsid"/) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $c->store_session_data( "session:$newsid" => $sessiondata ); | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return $newsid; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub delete_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_session: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my ( $c, $msg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $c->log->debug("Deleting session" . ( defined($msg) ? "($msg)" : '(no reason given)') ) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | # delete the session data | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $c->delete_session_data("${_}:${sid}") for qw/session expires flash/; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $c->delete_session_id($sid); | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | # reset the values in the context object | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # see the BEGIN block | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $c->_clear_session_instance_data; | |||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $c->_session_delete_reason($msg); | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub session_delete_reason { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_delete_reason: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $c->session_is_valid; # check that it was loaded | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $c->_session_delete_reason(@_); | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_expires: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if ( defined( my $expires = $c->_extended_session_expires ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return $expires; | |||||||||||||||||||||||||||||||||||||||||
| 380 | } elsif ( defined( $expires = $c->_load_session_expires ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return $c->extend_session_expires( $expires ); | |||||||||||||||||||||||||||||||||||||||||
| 382 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | sub extend_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extend_session_expires: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my ( $c, $expires ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | my $threshold = $c->_session_plugin_config->{expiry_threshold} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->_session_plugin_config->{'expiry_threshold'} || 0
MC/DC0%0/1
$c->_session_plugin_config->{'expiry_threshold'} || 0
$c->_session_plugin_config->{'expiry_threshold'}
Truth table0%0/2
A
A= $c->_session_plugin_config->{'expiry_threshold'}
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $expires = $c->_get_stored_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $cutoff = $expires - $threshold; | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if (!$threshold || $cutoff <= time || $c->_session_updated) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $threshold or $cutoff <= time or $c->_session_updated
not $threshold or $cutoff <= time
MC/DC0%0/3
not $threshold or $cutoff <= time or $c->_session_updated
not $threshold
$cutoff <= time
$c->_session_updated
Truth table0%0/4
not(A) or B or C
A= not $thresholdB= $cutoff <= timeC= $c->_session_updated
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $c->_extended_session_expires( my $updated = $c->calculate_initial_session_expires() ); | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $c->extend_session_id( $sid, $updated ); | |||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return $updated; | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | return $expires; | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub change_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_session_expires: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my ( $c, $expires ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | $expires ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$expires ||= 0
MC/DC0%0/1
$expires ||= 0
$expires
Truth table0%0/2
A
A= $expires
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $sid = $c->sessionid; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $time_exp = time() + $expires; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $c->store_session_data( "expires:$sid" => $time_exp ); | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 6 | ▶ | sub _get_stored_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_stored_session_expires: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 6 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 6 | ▶ | if ( my $sid = $c->sessionid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 6 | ▶ | return $c->get_session_data("expires:$sid") || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->get_session_data("expires:$sid") || 0
MC/DC0%0/1
$c->get_session_data("expires:$sid") || 0
$c->get_session_data("expires:$sid")
Truth table50%1/2
A
A= $c->get_session_data("expires:$sid")
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub initial_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initial_session_expires: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return ( time() + $c->_session_plugin_config->{expires} ); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub calculate_initial_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_initial_session_expires: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return max( $c->initial_session_expires, $c->_get_stored_session_expires ); | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub calculate_extended_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_extended_session_expires: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my ( $c, $prev ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return ( time() + $prev ); | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub reset_session_expires { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_session_expires: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my ( $c, $sid ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $exp = $c->calculate_initial_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $c->_session_expires( $exp ); | |||||||||||||||||||||||||||||||||||||||||
| 456 | # | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # since we're setting _session_expires directly, make load_session_expires | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # actually use that value. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | # | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $c->_tried_loading_session_expires(1); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $c->_extended_session_expires( $exp ); | |||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $exp; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 41 | ▶ | sub sessionid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sessionid: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 41 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 41 | ▶ | return $c->_sessionid || $c->_load_sessionid; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$c->_sessionid || $c->_load_sessionid
MC/DC0%0/2
$c->_sessionid || $c->_load_sessionid
$c->_sessionid
$c->_load_sessionid
Truth table33%1/3
A || B
A= $c->_sessionidB= $c->_load_sessionid
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | sub _load_sessionid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_sessionid: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | return if $c->_tried_loading_session_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $c->_tried_loading_session_id(1); | |||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if ( defined( my $sid = $c->get_session_id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ( $c->validate_session_id($sid) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | # temporarily set the inner key, so that validation will work | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $c->_sessionid($sid); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return $sid; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $sid = HTML::Entities::encode_entities($sid); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $err = "Tried to set invalid session ID '$sid'"; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $c->log->error($err); | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | Catalyst::Exception->throw($err); | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | sub session_is_valid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_is_valid: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | # force a check for expiry, but also __address, etc | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if ( $c->_load_session ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 498 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | sub validate_session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_session_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ( $c, $sid ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $sid and $sid =~ /^[a-f\d]+$/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 10 | ▶ | sub session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session: called CC=7 SCAR=29.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 10 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 10 | ▶ | my $session = $c->_session || $c->_load_session || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$c->_session || $c->_load_session || do {
$c->create_session_id_if_needed;
$c->initialize_session_data
}
$c->_session or $c->_load_session
MC/DC0%0/3
$c->_session || $c->_load_session || do {
$c->create_session_id_if_needed;
$c->initialize_session_data
}
$c->_session
$c->_load_session
do {
$c->create_session_id_if_needed;
$c->initialize_session_data
}
Truth table50%2/4
A or B || C
A= $c->_sessionB= $c->_load_sessionC= do {
$c->create_session_id_if_needed;
$c->initialize_session_data
}
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $c->create_session_id_if_needed; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $c->initialize_session_data; | |||||||||||||||||||||||||||||||||||||||||
| 515 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 10 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | my $new_values = @_ > 1 ? { @_ } : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | croak('session takes a hash or hashref') unless ref $new_values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | for my $key (keys %$new_values) { | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $session->{$key} = $new_values->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 10 | $session; | |||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub keep_flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keep_flash: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ( $c, @keys ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $href = $c->_flash_keep_keys || $c->_flash_keep_keys({}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$c->_flash_keep_keys || $c->_flash_keep_keys({})
MC/DC0%0/2
$c->_flash_keep_keys || $c->_flash_keep_keys({})
$c->_flash_keep_keys
$c->_flash_keep_keys({})
Truth table0%0/3
A || B
A= $c->_flash_keep_keysB= $c->_flash_keep_keys({})
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | (@{$href}{@keys}) = ((undef) x @keys); | |||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 13 | ▶ | sub _flash_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flash_data: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 13 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 13 | ▶ | $c->_flash || $c->_load_flash || do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c->_flash or $c->_load_flash
MC/DC100%2/2
$c->_flash or $c->_load_flash
$c->_flash
$c->_load_flash
Truth table100%3/3
A or B
A= $c->_flashB= $c->_load_flash
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | $c->create_session_id_if_needed; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | $c->_flash( {} ); | |||||||||||||||||||||||||||||||||||||||||
| 540 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 13 | ▶ | sub _set_flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_flash: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 13 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 13 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 1 | ▶ | my $items = @_ > 1 ? {@_} : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | ▶ | croak('flash takes a hash or hashref') unless ref $items; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | @{ $c->_flash }{ keys %$items } = values %$items; | |||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 13 | ▶ | sub flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 13 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 13 | $c->_flash_data; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 13 | $c->_set_flash(@_); | |||||||||||||||||||||||||||||||||||||||||
| 556 | 13 | return $c->_flash; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 1 | ▶ | sub clear_flash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_flash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | #$c->delete_session_data("flash:" . $c->sessionid); # should this be in here? or delayed till finalization? | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 1 | $c->_flash_key_hashes({}); | |||||||||||||||||||||||||||||||||||||||||
| 564 | 1 | $c->_flash_keep_keys({}); | |||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | $c->_flash({}); | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub session_expire_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_expire_key: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my ( $c, %keys ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | @{ $c->session->{__expire_keys} }{ keys %keys } = | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | map { $now + $_ } values %keys; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub initialize_session_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_session_data: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $now = time; | |||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | return $c->_session( | ||||||||||||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||||||||||||
| 583 | __created => $now, | ||||||||||||||||||||||||||||||||||||||||||
| 584 | __updated => $now, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 587 | $c->_session_plugin_config->{verify_address} | ||||||||||||||||||||||||||||||||||||||||||
| 588 | ? ( __address => $c->request->address||'' ) | ||||||||||||||||||||||||||||||||||||||||||
| 589 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 590 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 591 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 592 | $c->_session_plugin_config->{verify_user_agent} | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | ? ( __user_agent => $c->request->user_agent||'' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/4
$c->request->address or ""
$c->request->user_agent or ""
MC/DC0%0/1
$c->request->address or ""
$c->request->address
MC/DC0%0/1
$c->request->user_agent or ""
$c->request->user_agent
Truth table0%0/2
A
A= $c->request->address
Truth table0%0/2
A
A= $c->request->user_agent
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 595 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | sub generate_session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | return unpack( "H*", Crypt::SysRandom::random_bytes(20) ); | |||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | 3 | ▶ | sub create_session_id_if_needed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_session_id_if_needed: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 3 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 3 | ▶ | $c->create_session_id unless $c->sessionid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | sub create_session_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_session_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $sid = $c->generate_session_id; | |||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $c->log->debug(qq/Created session "$sid"/) if $c->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $c->_sessionid($sid); | |||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $c->reset_session_expires; | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | $c->set_session_id($sid); | |||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | return $sid; | |||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 3 | my $counter; | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub session_hash_seed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_hash_seed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return Crypt::SysRandom::random_bytes( 20 ); | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | sub dump_these { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_these: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | $c->maybe::next::method(), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | $c->_sessionid | ||||||||||||||||||||||||||||||||||||||||||
| 636 | ? ( [ "Session ID" => $c->sessionid ], [ Session => $c->session ], ) | ||||||||||||||||||||||||||||||||||||||||||
| 637 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 638 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | sub get_session_id { shift->maybe::next::method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | sub set_session_id { shift->maybe::next::method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub delete_session_id { shift->maybe::next::method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | sub extend_session_id { shift->maybe::next::method(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extend_session_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | __END__ | ||||||||||||||||||||||||||||||||||||||||||