« blib/lib/Lemonldap/NG/Common/OpenIDConnect/Metadata.pm
↑ Summary
blib/lib/Lemonldap/NG/Common/Notifications/LDAP.pm »
| 1 | package Lemonldap::NG::Common::Session::Purge; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Lemonldap::NG::Common::Conf; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Lemonldap::NG::Common::Conf::Constants; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Lemonldap::NG::Common::Apache::Session; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Lemonldap::NG::Common::Session; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Lemonldap::NG::Common::Safelib; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Lemonldap::NG::Common::PSGI::Request; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use POSIX qw(strftime); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use constant defaultLogger => 'Lemonldap::NG::Common::Logger::Std'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 2 | has logLevel => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||
| 18 | 2 | has force => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||
| 19 | 2 | has audit => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||
| 20 | 2 | has json => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||
| 21 | has conf => ( | ||||||||||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $ca = Lemonldap::NG::Common::Conf->new() | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | or die $Lemonldap::NG::Common::Conf::msg; | ||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $conf = | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
my $conf = $ca->getConf or die "Unable to get configuration ($!)"
MC/DC0%0/1
my $conf = $ca->getConf or die "Unable to get configuration ($!)"
my $conf = $ca->getConf
Truth table0%0/2
A
A= my $conf = $ca->getConf
| |||||||||||||||||||||||||||||||||||
| 27 | $ca->getConf | ||||||||||||||||||||||||||||||||||
| 28 | or die "Unable to get configuration ($!)" | ||||||||||||||||||||||||||||||||||
| 29 | or die "Unable to get configuration ($!)"; | ||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $localconf = $ca->getLocalConf(PORTALSECTION) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 31 | or die "Unable to get local configuration ($!)"; | ||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($localconf) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | $conf->{$_} = $localconf->{$_} foreach ( keys %$localconf ); | |||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $conf->{logLevel} = $_[0]->logLevel || $conf->{logLevel} || 'info'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$_[0]->logLevel || $conf->{'logLevel'} || 'info'
$_[0]->logLevel or $conf->{"logLevel"}
MC/DC0%0/2
$_[0]->logLevel || $conf->{'logLevel'} || 'info'
$_[0]->logLevel
$conf->{"logLevel"}
Truth table0%0/3
A or B
A= $_[0]->logLevelB= $conf->{"logLevel"}
| |||||||||||||||||||||||||||||||||||
| 36 | 0 | return $conf; | |||||||||||||||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||||||||||||||||
| 38 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||
| 41 | has logger => ( | ||||||||||||||||||||||||||||||||||
| 42 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 45 | 0 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 46 | my $logger = | ||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $self->conf->{logger} || $ENV{LLNG_DEFAULTLOGGER} || defaultLogger; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->conf->{'logger'} || $ENV{'LLNG_DEFAULTLOGGER'} || 'Lemonldap::NG::Common::Logger::Std'
$self->conf->{"logger"} or $ENV{"LLNG_DEFAULTLOGGER"}
MC/DC0%0/2
$self->conf->{'logger'} || $ENV{'LLNG_DEFAULTLOGGER'} || 'Lemonldap::NG::Common::Logger::Std'
$self->conf->{"logger"}
$ENV{"LLNG_DEFAULTLOGGER"}
Truth table0%0/3
A or B
A= $self->conf->{"logger"}B= $ENV{"LLNG_DEFAULTLOGGER"}
| |||||||||||||||||||||||||||||||||||
| 48 | 0 | $logger =~ s/^::/Lemonldap::NG::Common::Logger::/; | |||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $logger = defaultLogger | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 50 | if $logger eq 'Lemonldap::NG::Common::Logger::Apache2'; | ||||||||||||||||||||||||||||||||||
| 51 | 0 | eval "require $logger"; | |||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | 0 | my $err; | |||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | unless ( $conf->{logLevel} =~ /^(?:debug|info|notice|warn|error)$/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 56 | 0 | $err = "Bad logLevel value $conf->{logLevel}, use 'info'"; | |||||||||||||||||||||||||||||||||
| 57 | 0 | $conf->{logLevel} = 'info'; | |||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||
| 59 | 0 | $logger = $logger->new($conf); | |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $logger->error($err) if $err; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 61 | 0 | return $logger; | |||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||
| 63 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | has userLogger => ( | ||||||||||||||||||||||||||||||||||
| 67 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 70 | 0 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 71 | my $logger = | ||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->conf->{userLogger} || $ENV{LLNG_USERLOGGER} || defaultLogger; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->conf->{'userLogger'} || $ENV{'LLNG_USERLOGGER'} || 'Lemonldap::NG::Common::Logger::Std'
$self->conf->{"userLogger"} or $ENV{"LLNG_USERLOGGER"}
MC/DC0%0/2
$self->conf->{'userLogger'} || $ENV{'LLNG_USERLOGGER'} || 'Lemonldap::NG::Common::Logger::Std'
$self->conf->{"userLogger"}
$ENV{"LLNG_USERLOGGER"}
Truth table0%0/3
A or B
A= $self->conf->{"userLogger"}B= $ENV{"LLNG_USERLOGGER"}
| |||||||||||||||||||||||||||||||||||
| 73 | 0 | $logger =~ s/^::/Lemonldap::NG::Common::Logger::/; | |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $logger = defaultLogger | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 75 | if $logger eq 'Lemonldap::NG::Common::Logger::Apache2'; | ||||||||||||||||||||||||||||||||||
| 76 | 0 | eval "require $logger"; | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | 0 | my $err; | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | unless ( $conf->{logLevel} =~ /^(?:debug|info|notice|warn|error)$/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | $err = "Bad logLevel value $conf->{logLevel}, use 'info'"; | |||||||||||||||||||||||||||||||||
| 82 | 0 | $conf->{logLevel} = 'info'; | |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | 0 | $logger = $logger->new($conf); | |||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $logger->error($err) if $err; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | 0 | return $logger; | |||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||
| 88 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | has _auditLogger => ( | ||||||||||||||||||||||||||||||||||
| 92 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 94 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 95 | 0 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 96 | my $logger = | ||||||||||||||||||||||||||||||||||
| 97 | $self->conf->{auditLogger} | ||||||||||||||||||||||||||||||||||
| 98 | || $ENV{LLNG_AUDITLOGGER} | ||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | || "Lemonldap::NG::Common::AuditLogger::UserLoggerCompat"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$self->conf->{'auditLogger'} || $ENV{'LLNG_AUDITLOGGER'} || 'Lemonldap::NG::Common::AuditLogger::UserLoggerCompat'
$self->conf->{"auditLogger"} or $ENV{"LLNG_AUDITLOGGER"}
MC/DC0%0/2
$self->conf->{'auditLogger'} || $ENV{'LLNG_AUDITLOGGER'} || 'Lemonldap::NG::Common::AuditLogger::UserLoggerCompat'
$self->conf->{"auditLogger"}
$ENV{"LLNG_AUDITLOGGER"}
Truth table0%0/3
A or B
A= $self->conf->{"auditLogger"}B= $ENV{"LLNG_AUDITLOGGER"}
| |||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | 0 | eval "require $logger"; | |||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | 0 | $logger = $logger->new($self); | |||||||||||||||||||||||||||||||||
| 105 | 0 | return $logger; | |||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||
| 107 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | has persistent_backend_options => ( | ||||||||||||||||||||||||||||||||||
| 111 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 112 | 9 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 113 | 9 | my $conf = $_[0]->conf; | |||||||||||||||||||||||||||||||||
| 114 | 9 | my $logger = $_[0]->logger; | |||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | 9 | my $type; | |||||||||||||||||||||||||||||||||
| 117 | my $options; | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | # sessions | ||||||||||||||||||||||||||||||||||
| 120 | 9 | ▶ | if ( $conf->{persistentStorage} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 121 | 9 | $type = 'persistent'; | |||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||||||||
| 124 | 0 | $type = 'global'; | |||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | # load module | ||||||||||||||||||||||||||||||||||
| 128 | 9 | my $module = $conf->{"${type}Storage"}; | |||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | eval "use $module"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 130 | 9 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||
| 132 | 9 | ▶ | $options = { %{ $conf->{"${type}StorageOptions"} // {} } }; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$conf{"${type}StorageOptions"} // {}
MC/DC0%0/1
$$conf{"${type}StorageOptions"} // {}
$$conf{"${type}StorageOptions"}
Truth table50%1/2
A
A= $$conf{"${type}StorageOptions"}
| |||||||||||||||||||||||||||||||||||
| 133 | 9 | $options->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | 9 | $logger->debug("persistent session backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 136 | 9 | return $options; | |||||||||||||||||||||||||||||||||
| 137 | }, | ||||||||||||||||||||||||||||||||||
| 138 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | has backends => ( | ||||||||||||||||||||||||||||||||||
| 142 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 143 | 8 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=23 SCAR=40.0
| |||||||||||||||||||||||||||||||||||
| 144 | 8 | my $conf = $_[0]->conf; | |||||||||||||||||||||||||||||||||
| 145 | 8 | my $logger = $_[0]->logger; | |||||||||||||||||||||||||||||||||
| 146 | 8 | my %backends; | |||||||||||||||||||||||||||||||||
| 147 | my $module; | ||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | # Sessions | ||||||||||||||||||||||||||||||||||
| 150 | 8 | ▶ | if ( $conf->{globalStorage} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||
| 152 | # Load module | ||||||||||||||||||||||||||||||||||
| 153 | 8 | $module = $conf->{globalStorage}; | |||||||||||||||||||||||||||||||||
| 154 | 8 | ▶ | eval "use $module"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 155 | 8 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 156 | 8 | $conf->{globalStorageOptions}->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | # Add module in managed backends | ||||||||||||||||||||||||||||||||||
| 159 | 8 | $backends{SSO} = $conf->{globalStorageOptions}; | |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 8 | $logger->debug("Session backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | # SAML | ||||||||||||||||||||||||||||||||||
| 165 | 8 | ▶ | if ( $conf->{samlStorage} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conf->{"samlStorage"} or keys %{$conf->{"samlStorageOptions"} ||= {};}
MC/DC0%0/2
$conf->{"samlStorage"} or keys %{$conf->{"samlStorageOptions"} ||= {};}
$conf->{"samlStorage"}
keys %{$conf->{"samlStorageOptions"} ||= {};}
Truth table33%1/3
A or B
A= $conf->{"samlStorage"}B= keys %{$conf->{"samlStorageOptions"} ||= {};}
| |||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | or keys %{ $conf->{samlStorageOptions} ||= {} } ) | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{"samlStorageOptions"} ||= {}
MC/DC0%0/1
$conf->{"samlStorageOptions"} ||= {}
$conf->{"samlStorageOptions"}
Truth table0%0/2
A
A= $conf->{"samlStorageOptions"}
| |||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | # Load module | ||||||||||||||||||||||||||||||||||
| 170 | 8 | ▶ | $module = $conf->{samlStorage} || $conf->{globalStorage}; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$conf->{'samlStorage'} || $conf->{'globalStorage'}
MC/DC0%0/2
$conf->{'samlStorage'} || $conf->{'globalStorage'}
$conf->{'samlStorage'}
$conf->{'globalStorage'}
Truth table33%1/3
A || B
A= $conf->{'samlStorage'}B= $conf->{'globalStorage'}
| |||||||||||||||||||||||||||||||||||
| 171 | 8 | ▶ | eval "use $module"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 172 | 8 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 173 | 8 | $conf->{samlStorageOptions}->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | # Add module in managed backends | ||||||||||||||||||||||||||||||||||
| 176 | 8 | $backends{SAML} = $conf->{samlStorageOptions}; | |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | 8 | $logger->debug("SAML backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||
| 181 | # CAS | ||||||||||||||||||||||||||||||||||
| 182 | 8 | ▶ | if ( $conf->{casStorage} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conf->{"casStorage"} or keys %{$conf->{"casStorageOptions"} ||= {};}
MC/DC0%0/2
$conf->{"casStorage"} or keys %{$conf->{"casStorageOptions"} ||= {};}
$conf->{"casStorage"}
keys %{$conf->{"casStorageOptions"} ||= {};}
Truth table33%1/3
A or B
A= $conf->{"casStorage"}B= keys %{$conf->{"casStorageOptions"} ||= {};}
| |||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | or keys %{ $conf->{casStorageOptions} ||= {} } ) | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{"casStorageOptions"} ||= {}
MC/DC0%0/1
$conf->{"casStorageOptions"} ||= {}
$conf->{"casStorageOptions"}
Truth table50%1/2
A
A= $conf->{"casStorageOptions"}
| |||||||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | # Load module | ||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $module = $conf->{casStorage} || $conf->{globalStorage}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$conf->{'casStorage'} || $conf->{'globalStorage'}
MC/DC0%0/2
$conf->{'casStorage'} || $conf->{'globalStorage'}
$conf->{'casStorage'}
$conf->{'globalStorage'}
Truth table0%0/3
A || B
A= $conf->{'casStorage'}B= $conf->{'globalStorage'}
| |||||||||||||||||||||||||||||||||||
| 188 | 0 | eval "use $module"; | |||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 190 | 0 | $conf->{casStorageOptions}->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | # Add module in managed backends | ||||||||||||||||||||||||||||||||||
| 193 | 0 | $backends{CAS} = $conf->{casStorageOptions}; | |||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | 0 | $logger->debug("CAS backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | # Captcha | ||||||||||||||||||||||||||||||||||
| 199 | 8 | ▶ | if ( $conf->{captchaStorage} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conf->{"captchaStorage"} or keys %{$conf->{"captchaStorageOptions"} ||= {};}
MC/DC0%0/2
$conf->{"captchaStorage"} or keys %{$conf->{"captchaStorageOptions"} ||= {};}
$conf->{"captchaStorage"}
keys %{$conf->{"captchaStorageOptions"} ||= {};}
Truth table33%1/3
A or B
A= $conf->{"captchaStorage"}B= keys %{$conf->{"captchaStorageOptions"} ||= {};}
| |||||||||||||||||||||||||||||||||||
| 200 | 8 | ▶ | or keys %{ $conf->{captchaStorageOptions} ||= {} } ) | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{"captchaStorageOptions"} ||= {}
MC/DC0%0/1
$conf->{"captchaStorageOptions"} ||= {}
$conf->{"captchaStorageOptions"}
Truth table50%1/2
A
A= $conf->{"captchaStorageOptions"}
| |||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | # Load module | ||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $module = $conf->{captchaStorage} || $conf->{globalStorage}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$conf->{'captchaStorage'} || $conf->{'globalStorage'}
MC/DC0%0/2
$conf->{'captchaStorage'} || $conf->{'globalStorage'}
$conf->{'captchaStorage'}
$conf->{'globalStorage'}
Truth table0%0/3
A || B
A= $conf->{'captchaStorage'}B= $conf->{'globalStorage'}
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | eval "use $module"; | |||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 207 | 0 | $conf->{captchaStorageOptions}->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||
| 209 | # Add module in managed backends | ||||||||||||||||||||||||||||||||||
| 210 | 0 | $backends{Captcha} = $conf->{captchaStorageOptions}; | |||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | 0 | $logger->debug("Captcha backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||
| 215 | # OpenIDConnect | ||||||||||||||||||||||||||||||||||
| 216 | 8 | ▶ | if ( $conf->{oidcStorage} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conf->{"oidcStorage"} or keys %{$conf->{"oidcStorageOptions"} ||= {};}
MC/DC0%0/2
$conf->{"oidcStorage"} or keys %{$conf->{"oidcStorageOptions"} ||= {};}
$conf->{"oidcStorage"}
keys %{$conf->{"oidcStorageOptions"} ||= {};}
Truth table33%1/3
A or B
A= $conf->{"oidcStorage"}B= keys %{$conf->{"oidcStorageOptions"} ||= {};}
| |||||||||||||||||||||||||||||||||||
| 217 | 8 | ▶ | or keys %{ $conf->{oidcStorageOptions} ||= {} } ) | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{"oidcStorageOptions"} ||= {}
MC/DC0%0/1
$conf->{"oidcStorageOptions"} ||= {}
$conf->{"oidcStorageOptions"}
Truth table50%1/2
A
A= $conf->{"oidcStorageOptions"}
| |||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | # Load module | ||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $module = $conf->{oidcStorage} || $conf->{globalStorage}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$conf->{'oidcStorage'} || $conf->{'globalStorage'}
MC/DC0%0/2
$conf->{'oidcStorage'} || $conf->{'globalStorage'}
$conf->{'oidcStorage'}
$conf->{'globalStorage'}
Truth table0%0/3
A || B
A= $conf->{'oidcStorage'}B= $conf->{'globalStorage'}
| |||||||||||||||||||||||||||||||||||
| 222 | 0 | eval "use $module"; | |||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 224 | 0 | $conf->{oidcStorageOptions}->{backend} = $module; | |||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | # Add module in managed backends | ||||||||||||||||||||||||||||||||||
| 227 | 0 | $backends{OIDC} = $conf->{oidcStorageOptions}; | |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 0 | $logger->debug("OIDC backend $module will be used"); | |||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||
| 231 | 8 | return \%backends; | |||||||||||||||||||||||||||||||||
| 232 | }, | ||||||||||||||||||||||||||||||||||
| 233 | 2 | lazy => 1, | |||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | 2 | has force => ( is => 'ro' ); | |||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | my %PSESSION_FILTERS = ( | ||||||||||||||||||||||||||||||||||
| 239 | age => { | ||||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||
| 241 | 8 | my ( $self, $entry, $value ) = @_; | |||||||||||||||||||||||||||||||||
| 242 | return ( defined( $entry->{_utime} ) | ||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | and $entry->{_utime} < ( time - $value ) ); | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $entry->{'_utime'} && $entry->{'_utime'} < &CORE::GLOBAL::time() - $value
MC/DC50%1/2
defined $entry->{'_utime'} && $entry->{'_utime'} < &CORE::GLOBAL::time() - $value
defined $entry->{'_utime'}
$entry->{'_utime'} < &CORE::GLOBAL::time() - $value
Truth table66%2/3
A && B
A= defined $entry->{'_utime'}B= $entry->{'_utime'} < &CORE::GLOBAL::time() - $value
| |||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||||||||
| 246 | update => { | ||||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||
| 248 | 2 | my ( $self, $entry, $value ) = @_; | |||||||||||||||||||||||||||||||||
| 249 | 2 | my $min_updateTime = | |||||||||||||||||||||||||||||||||
| 250 | strftime( "%Y%m%d%H%M%S", localtime( time - $value ) ); | ||||||||||||||||||||||||||||||||||
| 251 | my $filter_result = ( defined( $entry->{_updateTime} ) | ||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | and $entry->{_updateTime} < $min_updateTime ); | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $entry->{'_updateTime'} && $entry->{'_updateTime'} < $min_updateTime
MC/DC50%1/2
defined $entry->{'_updateTime'} && $entry->{'_updateTime'} < $min_updateTime
defined $entry->{'_updateTime'}
$entry->{'_updateTime'} < $min_updateTime
Truth table66%2/3
A && B
A= defined $entry->{'_updateTime'}B= $entry->{'_updateTime'} < $min_updateTime
| |||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||
| 254 | }, | ||||||||||||||||||||||||||||||||||
| 255 | login => { | ||||||||||||||||||||||||||||||||||
| 256 | 12 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 257 | 12 | my ( $self, $entry, $value ) = @_; | |||||||||||||||||||||||||||||||||
| 258 | my $lastLogin = | ||||||||||||||||||||||||||||||||||
| 259 | 12 | $entry->{_loginHistory}->{successLogin}->[0]->{_utime}; | |||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | 12 | ▶ | my $filter_result = ( | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
!defined($lastLogin) || defined $value && $lastLogin < &CORE::GLOBAL::time() - $value
defined $value and $lastLogin < &CORE::GLOBAL::time() - $value
MC/DC100%3/3
!defined($lastLogin) || defined $value && $lastLogin < &CORE::GLOBAL::time() - $value
!defined($lastLogin)
defined $value
$lastLogin < &CORE::GLOBAL::time() - $value
Truth table100%4/4
not(A) || B and C
A= !defined($lastLogin)B= defined $valueC= $lastLogin < &CORE::GLOBAL::time() - $value
| |||||||||||||||||||||||||||||||||||
| 262 | not defined($lastLogin) | ||||||||||||||||||||||||||||||||||
| 263 | or ( defined($value) and ( $lastLogin < ( time - $value ) ) ) | ||||||||||||||||||||||||||||||||||
| 264 | ); | ||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||
| 266 | }, | ||||||||||||||||||||||||||||||||||
| 267 | sfdevice => { | ||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | filter => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 269 | 3 | my ( $self, $entry, $value ) = @_; | |||||||||||||||||||||||||||||||||
| 270 | 3 | return !Lemonldap::NG::Common::Safelib::has2f_internal($entry); | |||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||
| 272 | }, | ||||||||||||||||||||||||||||||||||
| 273 | 2 | ); | |||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | 8 | ▶ | sub purge { | ||||||||||||||||||||||||||||||||
|
Subroutine
purge: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 276 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||
| 278 | 8 | my $internal_stats; | |||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||
| 280 | # Compute the list of backends here to avoid having big timing | ||||||||||||||||||||||||||||||||||
| 281 | # inconsistencies | ||||||||||||||||||||||||||||||||||
| 282 | 8 | my $backends = $self->backends; | |||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | # Trigger lazy init | ||||||||||||||||||||||||||||||||||
| 285 | 8 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | 8 | $self->logger->info("Session purge started"); | |||||||||||||||||||||||||||||||||
| 288 | 8 | $internal_stats->{start_time}->{total} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||
| 290 | 8 | ▶ | while ( my ( $type, $options ) = each %$backends ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 291 | 16 | $self->_purge_for_backend( $type, $options, $internal_stats ); | |||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||
| 294 | 8 | $internal_stats->{end_time}->{total} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | 8 | my $total_purged = 0; | |||||||||||||||||||||||||||||||||
| 297 | 8 | $total_purged += $_ for values %{ $internal_stats->{nb_purged} }; | |||||||||||||||||||||||||||||||||
| 298 | 8 | $internal_stats->{nb_purged}->{total} = $total_purged; | |||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | 8 | my $total_error = 0; | |||||||||||||||||||||||||||||||||
| 301 | 8 | $total_error += $_ for values %{ $internal_stats->{nb_error} }; | |||||||||||||||||||||||||||||||||
| 302 | 8 | $internal_stats->{nb_error}->{total} = $total_error; | |||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | 8 | my $return_stats; | |||||||||||||||||||||||||||||||||
| 305 | 8 | for my $type ( "total", sort keys %{ $self->backends } ) { | |||||||||||||||||||||||||||||||||
| 306 | 24 | $return_stats->{$type}->{errors} = $internal_stats->{nb_error}->{$type}; | |||||||||||||||||||||||||||||||||
| 307 | $return_stats->{$type}->{purged} = | ||||||||||||||||||||||||||||||||||
| 308 | 24 | $internal_stats->{nb_purged}->{$type}; | |||||||||||||||||||||||||||||||||
| 309 | $return_stats->{$type}->{duration_u} = int( | ||||||||||||||||||||||||||||||||||
| 310 | 1000000 * ( | ||||||||||||||||||||||||||||||||||
| 311 | $internal_stats->{end_time}->{$type} - | ||||||||||||||||||||||||||||||||||
| 312 | 24 | $internal_stats->{start_time}->{$type} | |||||||||||||||||||||||||||||||||
| 313 | ) | ||||||||||||||||||||||||||||||||||
| 314 | ); | ||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||
| 317 | 8 | my $log = "Session purge completed: "; | |||||||||||||||||||||||||||||||||
| 318 | 8 | ▶ | if ( $self->json ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 319 | 0 | $log .= to_json($return_stats); | |||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||
| 321 | else { | ||||||||||||||||||||||||||||||||||
| 322 | 8 | my @logentries; | |||||||||||||||||||||||||||||||||
| 323 | 8 | for my $type ( "total", sort keys %{ $self->backends } ) { | |||||||||||||||||||||||||||||||||
| 324 | 24 | my $logentry .= "$type ("; | |||||||||||||||||||||||||||||||||
| 325 | 24 | $logentry .= $return_stats->{$type}->{purged} . " purged, "; | |||||||||||||||||||||||||||||||||
| 326 | 24 | $logentry .= $return_stats->{$type}->{errors} . " errors in "; | |||||||||||||||||||||||||||||||||
| 327 | 24 | $logentry .= $return_stats->{$type}->{duration_u} . " us"; | |||||||||||||||||||||||||||||||||
| 328 | 24 | $logentry .= ")"; | |||||||||||||||||||||||||||||||||
| 329 | 24 | push @logentries, $logentry; | |||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||
| 331 | 8 | $log .= join( ', ', @logentries ); | |||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | 8 | $self->logger->notice($log); | |||||||||||||||||||||||||||||||||
| 335 | 8 | ▶ | $self->logger->warn( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 336 | "$total_error sessions remaining, try to purge them with force (option -f)" | ||||||||||||||||||||||||||||||||||
| 337 | ) if $total_error; | ||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||
| 339 | return { | ||||||||||||||||||||||||||||||||||
| 340 | 8 | success => !($total_error), | |||||||||||||||||||||||||||||||||
| 341 | purged => $total_purged, | ||||||||||||||||||||||||||||||||||
| 342 | errors => $total_error, | ||||||||||||||||||||||||||||||||||
| 343 | stats => $return_stats, | ||||||||||||||||||||||||||||||||||
| 344 | }; | ||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||
| 347 | 16 | ▶ | sub _purge_for_backend { | ||||||||||||||||||||||||||||||||
|
Subroutine
_purge_for_backend: called CC=19 SCAR=42.4
| |||||||||||||||||||||||||||||||||||
| 348 | 16 | my ( $self, $type, $options, $internal_stats ) = @_; | |||||||||||||||||||||||||||||||||
| 349 | 16 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 350 | 16 | $self->logger->debug("Cleaning $type sessions"); | |||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||
| 352 | 16 | $internal_stats->{nb_error}->{$type} = 0; | |||||||||||||||||||||||||||||||||
| 353 | 16 | $internal_stats->{nb_purged}->{$type} = 0; | |||||||||||||||||||||||||||||||||
| 354 | 16 | $internal_stats->{start_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||
| 356 | 16 | ▶ | if ( $options->{backend} eq "Apache::Session::Memcached" ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 357 | 0 | $internal_stats->{end_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 358 | 0 | return; | |||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||
| 361 | 16 | my @t; | |||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | # Memorize some OIDC parameters | ||||||||||||||||||||||||||||||||||
| 364 | 16 | my ( $rpActivity, $rtMinTimeout ); | |||||||||||||||||||||||||||||||||
| 365 | 16 | ▶ | foreach my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) { | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'oidcRPMetaDataOptions'} || {}
MC/DC0%0/1
$conf->{'oidcRPMetaDataOptions'} || {}
$conf->{'oidcRPMetaDataOptions'}
Truth table50%1/2
A
A= $conf->{'oidcRPMetaDataOptions'}
| |||||||||||||||||||||||||||||||||||
| 366 | my $v = $conf->{oidcRPMetaDataOptions}->{$rp} | ||||||||||||||||||||||||||||||||||
| 367 | 0 | ->{oidcRPMetaDataOptionsRtActivity}; | |||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | next unless $v; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | # Store the mapping ClientID -> RT timeout | ||||||||||||||||||||||||||||||||||
| 371 | $rpActivity->{ $conf->{oidcRPMetaDataOptions}->{$rp} | ||||||||||||||||||||||||||||||||||
| 372 | 0 | ->{oidcRPMetaDataOptionsClientID} } = $v; | |||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $rtMinTimeout = $v if !$rpActivity or $v < $rpActivity; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $rpActivity or $v < $rpActivity
MC/DC0%0/2
not $rpActivity or $v < $rpActivity
not $rpActivity
$v < $rpActivity
Truth table0%0/3
not(A) or B
A= not $rpActivityB= $v < $rpActivity
| |||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | my $checkRtExpiration = sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 377 | 0 | my ( $id, $session ) = @_; | |||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | return unless $session->{_session_kind} eq 'OIDCI'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | return unless $session->{_type} eq 'refresh_token'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | my $v = $session->{_oidcRtUpdate} or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | my $timeout = $rpActivity->{ $session->{client_id} } or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | push @t, $id if $v + $timeout < time; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 383 | 16 | }; | |||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||
| 385 | 16 | my $purge_done = 0; | |||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | # Real purge | ||||||||||||||||||||||||||||||||||
| 388 | 16 | ▶ | if ( $options->{backend}->can('deleteIfLowerThan') ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 389 | 4 | $self->logger->debug("Found deleteIfLowerThan() in backend, using it"); | |||||||||||||||||||||||||||||||||
| 390 | my ( $success, $rows ) = $options->{backend}->deleteIfLowerThan( | ||||||||||||||||||||||||||||||||||
| 391 | $options, | ||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||
| 393 | not => { '_session_kind' => 'Persistent' }, | ||||||||||||||||||||||||||||||||||
| 394 | or => { | ||||||||||||||||||||||||||||||||||
| 395 | _utime => time - $conf->{timeout}, | ||||||||||||||||||||||||||||||||||
| 396 | ( | ||||||||||||||||||||||||||||||||||
| 397 | $conf->{timeoutActivity} | ||||||||||||||||||||||||||||||||||
| 398 | ? ( _lastSeen => time - $conf->{timeoutActivity} ) | ||||||||||||||||||||||||||||||||||
| 399 | 4 | ▶ | : () | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 400 | ) | ||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||
| 403 | ); | ||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | 4 | ▶ | if ($success) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ($rows) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 407 | 0 | $internal_stats->{nb_purged}->{$type} += $rows; | |||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ($rtMinTimeout) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 410 | my $rtSessions = $options->{backend} | ||||||||||||||||||||||||||||||||||
| 411 | 0 | ->searchLt( $options, '_oidcRtUpdate', time - $rtMinTimeout ); | |||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ($rtSessions) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 413 | 0 | foreach my $id ( keys %$rtSessions ) { | |||||||||||||||||||||||||||||||||
| 414 | 0 | $checkRtExpiration->( $id, $rtSessions->{$id} ); | |||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||
| 418 | 0 | $internal_stats->{end_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | 0 | $purge_done = 1; | |||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | return unless @t; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||
| 423 | else { | ||||||||||||||||||||||||||||||||||
| 424 | 4 | $self->logger->notice( | |||||||||||||||||||||||||||||||||
| 425 | "deleteIfLowerThan failed during session purge" | ||||||||||||||||||||||||||||||||||
| 426 | . ", falling back to slower session enumeration" ); | ||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||
| 430 | # If deleteIfLowerThan missing OR deleteIfLowerThan failed (#3656) | ||||||||||||||||||||||||||||||||||
| 431 | 16 | ▶ | if ( !$purge_done ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | # Get all expired sessions | ||||||||||||||||||||||||||||||||||
| 434 | Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions( | ||||||||||||||||||||||||||||||||||
| 435 | $options, | ||||||||||||||||||||||||||||||||||
| 436 | 21 | ▶ | sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.7
| |||||||||||||||||||||||||||||||||||
| 437 | 21 | my $entry = shift; | |||||||||||||||||||||||||||||||||
| 438 | 21 | my $id = shift; | |||||||||||||||||||||||||||||||||
| 439 | 21 | my $time = time; | |||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | 21 | $self->logger->debug("Check session $id"); | |||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | # Empty session need to be removed | ||||||||||||||||||||||||||||||||||
| 444 | 21 | ▶ | unless ($entry) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 445 | 0 | push @t, $id; | |||||||||||||||||||||||||||||||||
| 446 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||
| 447 | "Session $id is empty (corrupted?), delete forced"); | ||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||
| 450 | # Do net check sessions without _utime | ||||||||||||||||||||||||||||||||||
| 451 | 21 | ▶ | return undef unless $entry->{_utime}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||
| 453 | # Do not expire persistent sessions | ||||||||||||||||||||||||||||||||||
| 454 | 21 | ▶ | return undef if ( $entry->{_session_kind} eq "Persistent" ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | # Session expired | ||||||||||||||||||||||||||||||||||
| 457 | 19 | ▶ | if ( $time - $entry->{_utime} > $conf->{timeout} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 458 | 10 | push @t, $id; | |||||||||||||||||||||||||||||||||
| 459 | 10 | $self->logger->debug("Session $id expired"); | |||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | # User has no activity, so considere the session has expired | ||||||||||||||||||||||||||||||||||
| 463 | ▶ | elsif ( $conf->{timeoutActivity} | |||||||||||||||||||||||||||||||||
|
Condition83%5/6
$conf->{"timeoutActivity"} and $entry->{"_lastSeen"} and $time - $entry->{"_lastSeen"} > $conf->{"timeoutActivity"}
$conf->{"timeoutActivity"} and $entry->{"_lastSeen"}
MC/DC66%2/3
$conf->{"timeoutActivity"} and $entry->{"_lastSeen"} and $time - $entry->{"_lastSeen"} > $conf->{"timeoutActivity"}
$conf->{"timeoutActivity"}
$entry->{"_lastSeen"}
$time - $entry->{"_lastSeen"} > $conf->{"timeoutActivity"}
Truth table75%3/4
A and B and C
A= $conf->{"timeoutActivity"}B= $entry->{"_lastSeen"}C= $time - $entry->{"_lastSeen"} > $conf->{"timeoutActivity"}
| |||||||||||||||||||||||||||||||||||
| 464 | and $entry->{_lastSeen} | ||||||||||||||||||||||||||||||||||
| 465 | and $time - $entry->{_lastSeen} > $conf->{timeoutActivity} ) | ||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||
| 467 | 2 | push @t, $id; | |||||||||||||||||||||||||||||||||
| 468 | 2 | $self->logger->debug("Session $id inactive"); | |||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||
| 470 | elsif ($rtMinTimeout) { | ||||||||||||||||||||||||||||||||||
| 471 | 0 | $checkRtExpiration->( $id, $entry ); | |||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||
| 473 | 19 | undef; | |||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||
| 475 | 16 | ); | |||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||
| 478 | # Delete sessions | ||||||||||||||||||||||||||||||||||
| 479 | 16 | my @errors; | |||||||||||||||||||||||||||||||||
| 480 | 16 | for my $id (@t) { | |||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||
| 482 | my $session = Lemonldap::NG::Common::Session->new( | ||||||||||||||||||||||||||||||||||
| 483 | storageModule => $options->{backend}, | ||||||||||||||||||||||||||||||||||
| 484 | storageModuleOptions => $options, | ||||||||||||||||||||||||||||||||||
| 485 | cacheModule => $conf->{localSessionStorage}, | ||||||||||||||||||||||||||||||||||
| 486 | cacheModuleOptions => $conf->{localSessionStorageOptions}, | ||||||||||||||||||||||||||||||||||
| 487 | 12 | id => $id, | |||||||||||||||||||||||||||||||||
| 488 | ); | ||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||
| 490 | 12 | ▶ | unless ( $session->data ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 491 | 0 | $self->logger->debug("Error while opening session $id"); | |||||||||||||||||||||||||||||||||
| 492 | 0 | print STDERR "Error on session $id\n"; | |||||||||||||||||||||||||||||||||
| 493 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 494 | 0 | push @errors, $id; | |||||||||||||||||||||||||||||||||
| 495 | 0 | next; | |||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||
| 498 | 12 | ▶ | unless ( $session->remove ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 499 | 0 | $self->logger->debug("Error while deleting session $id"); | |||||||||||||||||||||||||||||||||
| 500 | 0 | print STDERR "Error on session $id\n"; | |||||||||||||||||||||||||||||||||
| 501 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 502 | 0 | push @errors, $id; | |||||||||||||||||||||||||||||||||
| 503 | 0 | next; | |||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||
| 505 | 12 | $self->logger->debug("Session $id has been purged"); | |||||||||||||||||||||||||||||||||
| 506 | 12 | $internal_stats->{nb_purged}->{$type}++; | |||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||
| 509 | 16 | $self->_cleanup_lock_files( $type, $options, $internal_stats ); | |||||||||||||||||||||||||||||||||
| 510 | 16 | $self->_cleanup_errors( $type, $options, $internal_stats, \@errors ); | |||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||
| 512 | 16 | $internal_stats->{end_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||
| 515 | 16 | ▶ | sub _cleanup_lock_files { | ||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_lock_files: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||
| 516 | 16 | my ( $self, $type, $options, $internal_stats ) = @_; | |||||||||||||||||||||||||||||||||
| 517 | 16 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||
| 519 | # Remove lock files for File backend | ||||||||||||||||||||||||||||||||||
| 520 | 16 | ▶ | if ( $options->{backend} =~ /^Apache::Session::(?:Browseable::)?File$/i ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 521 | 16 | require Apache::Session::Lock::File; | |||||||||||||||||||||||||||||||||
| 522 | 16 | my $l = Apache::Session::Lock::File->new; | |||||||||||||||||||||||||||||||||
| 523 | 16 | ▶ | my $lock_directory = $options->{LockDirectory} || $options->{Directory}; | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options->{'LockDirectory'} || $options->{'Directory'}
MC/DC0%0/2
$options->{'LockDirectory'} || $options->{'Directory'}
$options->{'LockDirectory'}
$options->{'Directory'}
Truth table33%1/3
A || B
A= $options->{'LockDirectory'}B= $options->{'Directory'}
| |||||||||||||||||||||||||||||||||||
| 524 | 16 | $l->clean( $lock_directory, $conf->{timeout} ); | |||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||
| 526 | 16 | return; | |||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||
| 529 | 16 | ▶ | sub _cleanup_errors { | ||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_errors: called CC=26 SCAR=61.9
| |||||||||||||||||||||||||||||||||||
| 530 | 16 | my ( $self, $type, $options, $internal_stats, $errors_ref ) = @_; | |||||||||||||||||||||||||||||||||
| 531 | 16 | my @errors = @$errors_ref; | |||||||||||||||||||||||||||||||||
| 532 | 16 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||
| 534 | # Force deletion of corrupted sessions for File backend | ||||||||||||||||||||||||||||||||||
| 535 | 16 | ▶ | if ( $options->{backend} =~ /^Apache::Session::(?:Browseable::)?File$/i | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?File$/i and $self->force
MC/DC0%0/2
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?File$/i and $self->force
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?File$/i
$self->force
Truth table33%1/3
A and B
A= $options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?File$/iB= $self->force
| |||||||||||||||||||||||||||||||||||
| 536 | and $self->force ) | ||||||||||||||||||||||||||||||||||
| 537 | { | ||||||||||||||||||||||||||||||||||
| 538 | 0 | foreach (@errors) { | |||||||||||||||||||||||||||||||||
| 539 | 0 | my $id = $_; | |||||||||||||||||||||||||||||||||
| 540 | 0 | eval { unlink $options->{Directory} . "/$id"; }; | |||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->logger->error("Unable to remove session $id"); | |||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||
| 544 | else { | ||||||||||||||||||||||||||||||||||
| 545 | 0 | $self->logger->warn("Session $id removed with force"); | |||||||||||||||||||||||||||||||||
| 546 | 0 | $internal_stats->{nb_error}->{$type}--; | |||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||
| 551 | # Force deletion of corrupted sessions for DBI backend | ||||||||||||||||||||||||||||||||||
| 552 | 16 | ▶ | if ( $options->{backend} =~ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/i and $self->force
MC/DC0%0/2
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/i and $self->force
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/i
$self->force
Truth table33%1/3
A and B
A= $options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/iB= $self->force
| |||||||||||||||||||||||||||||||||||
| 553 | /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/i | ||||||||||||||||||||||||||||||||||
| 554 | and $self->force ) | ||||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||
| 556 | my $dbi = DBI->connect_cached( $options->{DataSource}, | ||||||||||||||||||||||||||||||||||
| 557 | 0 | $options->{UserName}, $options->{Password} ); | |||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | my $table = $options->{TableName} || "sessions"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options->{'TableName'} || 'sessions'
MC/DC0%0/1
$options->{'TableName'} || 'sessions'
$options->{'TableName'}
Truth table0%0/2
A
A= $options->{'TableName'}
| |||||||||||||||||||||||||||||||||||
| 559 | 0 | my $req = $dbi->prepare("DELETE from $table WHERE id=?"); | |||||||||||||||||||||||||||||||||
| 560 | 0 | foreach (@errors) { | |||||||||||||||||||||||||||||||||
| 561 | 0 | my $id = $_; | |||||||||||||||||||||||||||||||||
| 562 | 0 | my $res = $req->execute($id); | |||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | unless ( $res == 1 ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 564 | 0 | $self->logger->error("Fail to delete session $id with force"); | |||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||
| 566 | else { | ||||||||||||||||||||||||||||||||||
| 567 | 0 | $self->logger->warn("Session $id removed with force"); | |||||||||||||||||||||||||||||||||
| 568 | 0 | $internal_stats->{nb_error}->{$type}--; | |||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||
| 573 | # Force deletion of corrupted sessions for LDAP backend | ||||||||||||||||||||||||||||||||||
| 574 | 16 | ▶ | if ( $options->{backend} =~ /^Apache::Session::(?:Browseable::)?LDAP$/i | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?LDAP$/i and $self->force
MC/DC0%0/2
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?LDAP$/i and $self->force
$options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?LDAP$/i
$self->force
Truth table33%1/3
A and B
A= $options->{"backend"} =~ /^Apache::Session::(?:Browseable::)?LDAP$/iB= $self->force
| |||||||||||||||||||||||||||||||||||
| 575 | and $self->force ) | ||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||
| 577 | 0 | my $useTls = 0; | |||||||||||||||||||||||||||||||||
| 578 | 0 | my $tlsParam; | |||||||||||||||||||||||||||||||||
| 579 | 0 | my @servers = (); | |||||||||||||||||||||||||||||||||
| 580 | 0 | foreach my $server ( split /[\s,]+/, $options->{ldapServer} ) { | |||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 582 | 0 | $useTls = 1; | |||||||||||||||||||||||||||||||||
| 583 | 0 | $server = $1; | |||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | $tlsParam = $2 || ""; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 || ''
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||
| 586 | else { | ||||||||||||||||||||||||||||||||||
| 587 | 0 | $useTls = 0; | |||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||
| 589 | 0 | push @servers, $server; | |||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||
| 591 | 0 | my $ldap = | |||||||||||||||||||||||||||||||||
| 592 | Net::LDAP->new( \@servers, keepalive => 1, onerror => undef, ); | ||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | unless ($ldap) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 594 | 0 | print STDERR "Unable to connect to LDAP server\n"; | |||||||||||||||||||||||||||||||||
| 595 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 596 | 0 | return; | |||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||
| 599 | # Start TLS if needed | ||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if ($useTls) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 601 | 0 | my %h = split( /[&=]/, $tlsParam ); | |||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $h{verify} ||= $options->{ldapVerify} || "require"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$h{"verify"} ||= $options->{"ldapVerify"} || "require"
$options->{'ldapVerify'} || 'require'
MC/DC0%0/2
$h{"verify"} ||= $options->{"ldapVerify"} || "require"
$h{"verify"}
$options->{'ldapVerify'}
Truth table0%0/3
A ||= B
A= $h{"verify"}B= $options->{'ldapVerify'}
| |||||||||||||||||||||||||||||||||||
| 603 | $h{cafile} ||= $options->{ldapCAFile} | ||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if ( $options->{ldapCAFile} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"cafile"} ||= $options->{"ldapCAFile"}
MC/DC0%0/2
$h{"cafile"} ||= $options->{"ldapCAFile"}
$h{"cafile"}
$options->{"ldapCAFile"}
Truth table0%0/3
A ||= B
A= $h{"cafile"}B= $options->{"ldapCAFile"}
| |||||||||||||||||||||||||||||||||||
| 605 | $h{capath} ||= $options->{ldapCAPath} | ||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if ( $options->{ldapCAPath} ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"capath"} ||= $options->{"ldapCAPath"}
MC/DC0%0/2
$h{"capath"} ||= $options->{"ldapCAPath"}
$h{"capath"}
$options->{"ldapCAPath"}
Truth table0%0/3
A ||= B
A= $h{"capath"}B= $options->{"ldapCAPath"}
| |||||||||||||||||||||||||||||||||||
| 607 | 0 | my $start_tls = $ldap->start_tls(%h); | |||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if ( $start_tls->code ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 609 | 0 | print STDERR "STARTTLS error: " | |||||||||||||||||||||||||||||||||
| 610 | . $start_tls->code . ': ' | ||||||||||||||||||||||||||||||||||
| 611 | . $start_tls->error; | ||||||||||||||||||||||||||||||||||
| 612 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 613 | 0 | return; | |||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||
| 617 | my $bind = $ldap->bind( $options->{ldapBindDN}, | ||||||||||||||||||||||||||||||||||
| 618 | 0 | password => $options->{ldapBindPassword} ); | |||||||||||||||||||||||||||||||||
| 619 | 0 | my $attrId = $options->{ldapAttributeId} | "cn"; | |||||||||||||||||||||||||||||||||
| 620 | 0 | foreach (@errors) { | |||||||||||||||||||||||||||||||||
| 621 | 0 | my $id = $_; | |||||||||||||||||||||||||||||||||
| 622 | my $sessionDn = | ||||||||||||||||||||||||||||||||||
| 623 | 0 | $attrId . "=" . $id . "," . $options->{ldapConfBase}; | |||||||||||||||||||||||||||||||||
| 624 | 0 | my $delete = $ldap->delete($sessionDn); | |||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if ( $delete->is_error ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 626 | 0 | $self->logger->error("Fail to delete session $id with force"); | |||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||
| 628 | else { | ||||||||||||||||||||||||||||||||||
| 629 | 0 | $self->logger->warn("Session $id removed with force"); | |||||||||||||||||||||||||||||||||
| 630 | 0 | $internal_stats->{nb_error}->{$type}--; | |||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||
| 634 | 16 | return; | |||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||
| 637 | 9 | ▶ | sub persistentPurge { | ||||||||||||||||||||||||||||||||
|
Subroutine
persistentPurge: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 638 | 9 | my ( $self, $filters ) = @_; | |||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||
| 640 | 9 | my $internal_stats; | |||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||
| 642 | 9 | $self->logger->info("Persistent session purge started"); | |||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||
| 644 | 9 | $internal_stats->{start_time}->{total} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||
| 646 | 9 | $self->_purge_persistent( $filters, $internal_stats ); | |||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||
| 648 | 9 | $internal_stats->{end_time}->{total} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||
| 650 | 9 | my $total_purged = 0; | |||||||||||||||||||||||||||||||||
| 651 | 9 | $total_purged += $_ for values %{ $internal_stats->{nb_purged} }; | |||||||||||||||||||||||||||||||||
| 652 | 9 | $internal_stats->{nb_purged}->{total} = $total_purged; | |||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||
| 654 | 9 | my $total_error = 0; | |||||||||||||||||||||||||||||||||
| 655 | 9 | $total_error += $_ for values %{ $internal_stats->{nb_error} }; | |||||||||||||||||||||||||||||||||
| 656 | 9 | $internal_stats->{nb_error}->{total} = $total_error; | |||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||
| 658 | 9 | my $return_stats; | |||||||||||||||||||||||||||||||||
| 659 | 9 | for my $type ( "total", 'Persistent' ) { | |||||||||||||||||||||||||||||||||
| 660 | 18 | $return_stats->{$type}->{errors} = $internal_stats->{nb_error}->{$type}; | |||||||||||||||||||||||||||||||||
| 661 | $return_stats->{$type}->{purged} = | ||||||||||||||||||||||||||||||||||
| 662 | 18 | $internal_stats->{nb_purged}->{$type}; | |||||||||||||||||||||||||||||||||
| 663 | $return_stats->{$type}->{duration_u} = int( | ||||||||||||||||||||||||||||||||||
| 664 | 1000000 * ( | ||||||||||||||||||||||||||||||||||
| 665 | $internal_stats->{end_time}->{$type} - | ||||||||||||||||||||||||||||||||||
| 666 | 18 | $internal_stats->{start_time}->{$type} | |||||||||||||||||||||||||||||||||
| 667 | ) | ||||||||||||||||||||||||||||||||||
| 668 | ); | ||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||
| 671 | 9 | my $log = "Persistent session purge completed: "; | |||||||||||||||||||||||||||||||||
| 672 | 9 | ▶ | if ( $self->json ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 673 | 0 | $log .= to_json($return_stats); | |||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||
| 675 | else { | ||||||||||||||||||||||||||||||||||
| 676 | 9 | my @logentries; | |||||||||||||||||||||||||||||||||
| 677 | 9 | for my $type ( "total", "Persistent" ) { | |||||||||||||||||||||||||||||||||
| 678 | 18 | my $logentry .= "$type ("; | |||||||||||||||||||||||||||||||||
| 679 | 18 | $logentry .= $return_stats->{$type}->{purged} . " purged, "; | |||||||||||||||||||||||||||||||||
| 680 | 18 | $logentry .= $return_stats->{$type}->{errors} . " errors in "; | |||||||||||||||||||||||||||||||||
| 681 | 18 | $logentry .= $return_stats->{$type}->{duration_u} . " us"; | |||||||||||||||||||||||||||||||||
| 682 | 18 | $logentry .= ")"; | |||||||||||||||||||||||||||||||||
| 683 | 18 | push @logentries, $logentry; | |||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||
| 685 | 9 | $log .= join( ', ', @logentries ); | |||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||
| 688 | 9 | $self->logger->notice($log); | |||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||
| 690 | return { | ||||||||||||||||||||||||||||||||||
| 691 | 9 | success => 1, | |||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||
| 693 | purged => $total_purged, | ||||||||||||||||||||||||||||||||||
| 694 | errors => $total_error, | ||||||||||||||||||||||||||||||||||
| 695 | stats => $return_stats, | ||||||||||||||||||||||||||||||||||
| 696 | }; | ||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||
| 699 | 9 | ▶ | sub _purge_persistent { | ||||||||||||||||||||||||||||||||
|
Subroutine
_purge_persistent: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||
| 700 | 9 | my ( $self, $filters, $internal_stats ) = @_; | |||||||||||||||||||||||||||||||||
| 701 | 9 | my $type = "Persistent"; | |||||||||||||||||||||||||||||||||
| 702 | 9 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 703 | 9 | my $options = $self->persistent_backend_options; | |||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||
| 705 | 9 | my @t; | |||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||
| 707 | 9 | $internal_stats->{nb_error}->{$type} = 0; | |||||||||||||||||||||||||||||||||
| 708 | 9 | $internal_stats->{nb_purged}->{$type} = 0; | |||||||||||||||||||||||||||||||||
| 709 | 9 | $internal_stats->{start_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||
| 711 | # Get all expired sessions | ||||||||||||||||||||||||||||||||||
| 712 | Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions( | ||||||||||||||||||||||||||||||||||
| 713 | $options, | ||||||||||||||||||||||||||||||||||
| 714 | 22 | ▶ | sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||
| 715 | 22 | my $entry = shift; | |||||||||||||||||||||||||||||||||
| 716 | 22 | my $id = shift; | |||||||||||||||||||||||||||||||||
| 717 | 22 | my $time = time; | |||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||
| 719 | 22 | $self->logger->debug("Check session $id"); | |||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||
| 721 | 22 | ▶ | unless ($entry) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 722 | 0 | $self->logger->debug("Session $id is empty"); | |||||||||||||||||||||||||||||||||
| 723 | 0 | return; | |||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||
| 726 | # Ignore non-persistent sessions | ||||||||||||||||||||||||||||||||||
| 727 | 22 | ▶ | return unless ( $entry->{_session_kind} eq "Persistent" ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||
| 729 | # safety check: do not remove if there are no filters | ||||||||||||||||||||||||||||||||||
| 730 | 22 | ▶ | my $remove = keys %$filters ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||
| 732 | 22 | ▶ | while ( my ( $filter_type, $value ) = each %$filters ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 733 | 25 | ▶ | if ( my $filter_configuration = | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 734 | $PSESSION_FILTERS{$filter_type} ) | ||||||||||||||||||||||||||||||||||
| 735 | { | ||||||||||||||||||||||||||||||||||
| 736 | my $filter_result = | ||||||||||||||||||||||||||||||||||
| 737 | $filter_configuration->{filter} | ||||||||||||||||||||||||||||||||||
| 738 | 25 | ->( $self, $entry, $value ); | |||||||||||||||||||||||||||||||||
| 739 | 25 | $self->logger->debug( | |||||||||||||||||||||||||||||||||
| 740 | "$filter_type filter result: " . int($filter_result) ); | ||||||||||||||||||||||||||||||||||
| 741 | 25 | ▶ | $remove &&= $filter_result; | ||||||||||||||||||||||||||||||||
|
Condition100%3/3
$remove &&= $filter_result
MC/DC100%2/2
$remove &&= $filter_result
$remove
$filter_result
Truth table100%3/3
A &&= B
A= $removeB= $filter_result
| |||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||
| 743 | else { | ||||||||||||||||||||||||||||||||||
| 744 | 0 | $self->logger->debug("Unknown filter $filter_type"); | |||||||||||||||||||||||||||||||||
| 745 | 0 | $remove = 0; | |||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||
| 749 | 22 | ▶ | push @t, $id if $remove; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||
| 752 | 9 | ); | |||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||
| 754 | # Delete sessions | ||||||||||||||||||||||||||||||||||
| 755 | 9 | my @errors; | |||||||||||||||||||||||||||||||||
| 756 | 9 | for my $id (@t) { | |||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||
| 758 | my $session = Lemonldap::NG::Common::Session->new( | ||||||||||||||||||||||||||||||||||
| 759 | storageModule => $options->{backend}, | ||||||||||||||||||||||||||||||||||
| 760 | storageModuleOptions => $options, | ||||||||||||||||||||||||||||||||||
| 761 | cacheModule => $conf->{localSessionStorage}, | ||||||||||||||||||||||||||||||||||
| 762 | cacheModuleOptions => $conf->{localSessionStorageOptions}, | ||||||||||||||||||||||||||||||||||
| 763 | 12 | id => $id, | |||||||||||||||||||||||||||||||||
| 764 | ); | ||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||
| 766 | 12 | ▶ | unless ( $session->data ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 767 | 0 | $self->logger->debug("Error while opening session $id"); | |||||||||||||||||||||||||||||||||
| 768 | 0 | print STDERR "Error on session $id\n"; | |||||||||||||||||||||||||||||||||
| 769 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 770 | 0 | push @errors, $id; | |||||||||||||||||||||||||||||||||
| 771 | 0 | next; | |||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||
| 774 | 12 | ▶ | unless ( $session->remove ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 775 | 0 | $self->logger->debug("Error while deleting session $id"); | |||||||||||||||||||||||||||||||||
| 776 | 0 | print STDERR "Error on session $id\n"; | |||||||||||||||||||||||||||||||||
| 777 | 0 | $internal_stats->{nb_error}->{$type}++; | |||||||||||||||||||||||||||||||||
| 778 | 0 | push @errors, $id; | |||||||||||||||||||||||||||||||||
| 779 | 0 | next; | |||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||
| 781 | 12 | $self->logger->debug("Session $id has been purged"); | |||||||||||||||||||||||||||||||||
| 782 | 12 | ▶ | $self->_auditPurgePsession( $session->data ) if $self->audit; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 783 | 12 | $internal_stats->{nb_purged}->{$type}++; | |||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||
| 785 | 9 | $internal_stats->{end_time}->{$type} = Time::HiRes::time(); | |||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||
| 788 | 0 | ▶ | sub localPurge { | ||||||||||||||||||||||||||||||||
|
Subroutine
localPurge: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 789 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 790 | 0 | $self->logger->debug( __PACKAGE__ . "::localPurge() called" ); | |||||||||||||||||||||||||||||||||
| 791 | 0 | my $conf = $self->conf; | |||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | if ( $conf->{localSessionStorage} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 793 | 0 | eval "require $conf->{localSessionStorage}"; | |||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | $conf->{localSessionStorageOptions}->{default_expires_in} ||= 600; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{"localSessionStorageOptions"}{"default_expires_in"} ||= 600
MC/DC0%0/1
$conf->{"localSessionStorageOptions"}{"default_expires_in"} ||= 600
$conf->{"localSessionStorageOptions"}{"default_expires_in"}
Truth table0%0/2
A
A= $conf->{"localSessionStorageOptions"}{"default_expires_in"}
| |||||||||||||||||||||||||||||||||||
| 796 | my $s = $conf->{localSessionStorage} | ||||||||||||||||||||||||||||||||||
| 797 | 0 | ->new( $conf->{localSessionStorageOptions} ); | |||||||||||||||||||||||||||||||||
| 798 | 0 | $s->purge(); | |||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||
| 802 | 1 | ▶ | sub auditLog { | ||||||||||||||||||||||||||||||||
|
Subroutine
auditLog: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 803 | 1 | my ( $self, $req, %info ) = @_; | |||||||||||||||||||||||||||||||||
| 804 | 1 | $self->_auditLogger->log( $req, %info ); | |||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||
| 807 | 1 | ▶ | sub _auditPurgePsession { | ||||||||||||||||||||||||||||||||
|
Subroutine
_auditPurgePsession: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 808 | 1 | my ( $self, $session ) = @_; | |||||||||||||||||||||||||||||||||
| 809 | 1 | my $dummy_req = Lemonldap::NG::Common::PSGI::Request->new( | |||||||||||||||||||||||||||||||||
| 810 | { PATH_INFO => "", REQUEST_URI => "" } ); | ||||||||||||||||||||||||||||||||||
| 811 | 1 | my $uid = $session->{_session_uid}; | |||||||||||||||||||||||||||||||||
| 812 | 1 | $self->auditLog( | |||||||||||||||||||||||||||||||||
| 813 | $dummy_req, | ||||||||||||||||||||||||||||||||||
| 814 | message => ("Persistent session for $uid was removed"), | ||||||||||||||||||||||||||||||||||
| 815 | code => "PSESSION_REMOVED", | ||||||||||||||||||||||||||||||||||
| 816 | user => $uid, | ||||||||||||||||||||||||||||||||||
| 817 | ); | ||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||
| 820 | 2 | 1; | |||||||||||||||||||||||||||||||||