| 1 | package Lemonldap::NG::Handler::Main::Reload; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 26 | our $VERSION = '2.21.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Lemonldap::NG::Handler::Main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 28 | ▶ | use Digest::SHA qw(sha256_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 26 | ▶ | use Lemonldap::NG::Common::Conf::Constants; #inherits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 26 | ▶ | use Lemonldap::NG::Common::Crypto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 26 | ▶ | use Lemonldap::NG::Common::Safelib; #link protected safe Safe object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 26 | ▶ | use Lemonldap::NG::Handler::Main::Jail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 26 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 26 | ▶ | use constant UNPROTECT => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 26 | ▶ | use constant SKIP => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 26 | ▶ | use constant MAYSKIP => 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 26 | our @_onReload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub onReload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | my ( $class, $obj, $sub ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onReload: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | weaken($obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | push @_onReload, [ $obj, $sub ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # CONFIGURATION UPDATE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ## @rmethod protected int checkConf(boolean force) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Check if configuration is up to date, and reload it if needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # If the optional boolean $force is set to true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # * cached configuration is ignored | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # * and checkConf returns false if it fails to load remote config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # @param $force boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # @return true if config is up to date or if reload config succeeded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub checkConf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 60 | ▶ | my ( $class, $force ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkConf: called CC=22 SCAR=34.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 60 | $class->logger->debug("Check configuration for $class"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 60 | my $prm = { local => !$force, localPrm => $class->localConfig }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 60 | my $cfgNum = $class->confAcc->lastCfg(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 60 | ▶ | $prm->{local} = 0 if $class->cfgNum and $cfgNum != $class->cfgNum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$class->cfgNum and $cfgNum != $class->cfgNum
MC/DC100%2/2
$class->cfgNum and $cfgNum != $class->cfgNum
$class->cfgNum
$cfgNum != $class->cfgNum
Truth table100%3/3
A and B
A= $class->cfgNumB= $cfgNum != $class->cfgNum
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 60 | my $conf = $class->confAcc->getConf($prm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 60 | chomp $Lemonldap::NG::Common::Conf::msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 60 | ▶ | unless ( ref($conf) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | $class->logger->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | "$class: Unable to load configuration: $Lemonldap::NG::Common::Conf::msg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | return $force ? 0 : $class->cfgNum ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 55 | ▶ | if ($Lemonldap::NG::Common::Conf::msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 55 | ▶ | if ( $Lemonldap::NG::Common::Conf::msg =~ /Error:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | $class->logger->error($Lemonldap::NG::Common::Conf::msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | elsif ( $Lemonldap::NG::Common::Conf::msg =~ /Warn:/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $class->logger->warn($Lemonldap::NG::Common::Conf::msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 54 | $class->logger->debug($Lemonldap::NG::Common::Conf::msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 55 | $Lemonldap::NG::Common::Conf::msg = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 55 | ▶ | if ( $force | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%9/12
$force or not $class->cfgNum or not $class->cfgDate or $class->cfgNum != $conf->{"cfgNum"} or $class->cfgDate != $conf->{"cfgDate"}
$force or not $class->cfgNum or not $class->cfgDate or $class->cfgNum != $conf->{"cfgNum"}
$force or not $class->cfgNum or not $class->cfgDate
$force or not $class->cfgNum
MC/DC40%2/5
$force or not $class->cfgNum or not $class->cfgDate or $class->cfgNum != $conf->{"cfgNum"} or $class->cfgDate != $conf->{"cfgDate"}
$force
not $class->cfgNum
not $class->cfgDate
$class->cfgNum != $conf->{"cfgNum"}
$class->cfgDate != $conf->{"cfgDate"}
Truth table50%3/6
A or not(B) or not(C) or D or E
A= $forceB= not $class->cfgNumC= not $class->cfgDateD= $class->cfgNum != $conf->{"cfgNum"}E= $class->cfgDate != $conf->{"cfgDate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | or !$class->cfgNum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | or !$class->cfgDate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | or $class->cfgNum != $conf->{cfgNum} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | or $class->cfgDate != $conf->{cfgDate} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 45 | $class->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | "Get configuration $conf->{cfgNum} aged $conf->{cfgDate}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 45 | ▶ | unless ( $class->cfgNum( $conf->{cfgNum} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$class->cfgNum($conf->{"cfgNum"}) and $class->cfgDate($conf->{"cfgDate"})
MC/DC0%0/2
$class->cfgNum($conf->{"cfgNum"}) and $class->cfgDate($conf->{"cfgDate"})
$class->cfgNum($conf->{"cfgNum"})
$class->cfgDate($conf->{"cfgDate"})
Truth table33%1/3
A and B
A= $class->cfgNum($conf->{"cfgNum"})B= $class->cfgDate($conf->{"cfgDate"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | && $class->cfgDate( $conf->{cfgDate} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $class->logger->error('No configuration available'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 45 | $class->configReload($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 45 | foreach (@_onReload) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my ( $obj, $sub ) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | if ($obj) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $class->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 'Launching ' . ref($obj) . "->$sub(conf)" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | unless ( $obj->$sub($conf) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $class->logger->error( "Underlying object can't load conf (" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | . ref($obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | . "->$sub)" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( $obj->can('error') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $Lemonldap::NG::Common::Conf::msg = $obj->error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 55 | ▶ | $class->checkTime( $conf->{checkTime} ) if $conf->{checkTime}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 55 | ▶ | $class->checkMsg( $conf->{checkMsg} ) if $conf->{checkMsg}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 55 | $class->lastCheck( time() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 55 | $class->logger->debug("$class: configuration is up to date"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 55 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # RELOAD SYSTEM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ## @rmethod int reload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Launch checkConf() with $local=0, so remote configuration is tested. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Then build a simple HTTP response that just returns "200 OK" or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # "500 Server Error". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # @return Apache constant ($class->OK or $class->SERVER_ERROR) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub reload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | $class->logger->notice("Request for configuration reload"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | return $class->checkConf(1) ? $class->DONE : $class->SERVER_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 26 | *refresh = *reload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # INTERNAL METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ## @imethod void configReload(hashRef conf, hashRef tsv) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Given a Lemonldap::NG configuration $conf, computes values used to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # handle requests and store them in a thread shared object called $tsv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # methods called by configReload, and thread shared values computed, are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # - jailInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # - jail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # - defaultValuesInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # (scalars for global options) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # - cookieExpiration # warning: absent from default Conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # - cookieName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # - securedCookie, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # - httpOnly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # - whatToTrace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # - customFunctions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # - timeoutActivity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # - timeoutActivityInterval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # - useRedirectOnError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # - useRedirectOnForbidden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # - useRedirectAjaxOnUnauthorized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # - useSafeJail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # (objects) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # - cipher # Lemonldap::NG::Common::Crypto object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # (hashrefs for vhost options) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # - https | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # - port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # - maintenance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # - portalInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # - portal (functions that returns portal URL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # - locationRulesInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # - locationCount | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # - defaultCondition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # - defaultProtection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # - locationCondition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # - locationProtection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # - locationRegexp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # - locationConditionText | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # - sessionStorageInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # - sessionStorageModule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # - sessionStorageOptions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # - sessionCacheModule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # - sessionCacheOptions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # - headersInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # - headerList | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # - forgeHeaders | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # - postUrlInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # - inputPostData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # - outputPostData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # - aliasInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # - vhostAlias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # - oauth2Init(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # - oauth2Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # - msgBrokerInit(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # - msgBrokerWriter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # - msgBrokerReader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # The *Init() methods can be run in any order, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # but jailInit must be run first because $tsv->{jail} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # is used by locationRulesInit, headersInit and postUrlInit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # @param $conf reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # @param $tsv reference to the thread-shared parameters conf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | sub configReload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configReload: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 49 | $class->logger->info( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | "Loading configuration $conf->{cfgNum} for process $$"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 49 | foreach my $sub ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | qw( defaultValuesInit jailInit portalInit locationRulesInit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sessionStorageInit headersInit postUrlInit aliasInit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | oauth2Init msgBrokerInit ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 490 | $class->logger->debug("Process $$ calls $sub"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 490 | $class->$sub($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 49 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ## @imethod protected void jailInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # Set default values for non-customized variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub jailInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 50 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jailInit: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | $class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | useSafeJail => $conf->{useSafeJail}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | customFunctions => $conf->{customFunctions}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | multiValuesSeparator => $conf->{multiValuesSeparator}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 50 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $class->tsv->{jail} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 50 | ->build_jail( $class, $conf->{require}, $conf->{requireDontDie} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ## @imethod protected void defaultValuesInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Set default values for non-customized variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | sub defaultValuesInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 50 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaultValuesInit: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $class->tsv->{$_} = $conf->{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 50 | foreach ( qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | cookieExpiration cookieName customFunctions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | securedCookie timeout timeoutActivity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | timeoutActivityInterval useRedirectOnError useRedirectOnForbidden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | useSafeJail httpOnly whatToTrace handlerInternalCache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | handlerServiceTokenTTL customToTrace lwpOpts lwpSslOpts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | authChoiceAuthBasic authChoiceParam upgradeSession | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | hashedSessionStore eventQueueName eventStatus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | statusQueueName useRedirectAjaxOnUnauthorized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 50 | $class->tsv->{cipher} = Lemonldap::NG::Common::Crypto->new( $conf->{key} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 50 | $class->tsv->{keyH} = sha256_hex( $conf->{key} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 50 | foreach my $opt (qw(https port maintenance)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # Record default value in key '_' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 150 | $class->tsv->{$opt} = { _ => $conf->{$opt} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Override with vhost options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 150 | ▶ | if ( $conf->{vhostOptions} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 141 | my $name = 'vhost' . ucfirst($opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 141 | foreach my $vhost ( sort keys %{ $conf->{vhostOptions} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 240 | ▶ | $conf->{vhostOptions}->{$vhost} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{"vhostOptions"}{$vhost} ||= {}
MC/DC0%0/1
$conf->{"vhostOptions"}{$vhost} ||= {}
$conf->{"vhostOptions"}{$vhost}
Truth table50%1/2
A
A= $conf->{"vhostOptions"}{$vhost}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 240 | my $val = $conf->{vhostOptions}->{$vhost}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # Keep global value if $val is negative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 240 | ▶ | if ( defined $val and $val >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $val and $val >= 0
MC/DC50%1/2
defined $val and $val >= 0
defined $val
$val >= 0
Truth table66%2/3
A and B
A= defined $valB= $val >= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 67 | $class->logger->debug( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | "Options $opt for vhost $vhost: $val"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 67 | $class->tsv->{$opt}->{$vhost} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 50 | ▶ | if ( $conf->{vhostOptions} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 47 | foreach my $vhost ( sort keys %{ $conf->{vhostOptions} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $class->tsv->{type}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 80 | $conf->{vhostOptions}->{$vhost}->{vhostType}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | $class->tsv->{authnLevel}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 80 | $conf->{vhostOptions}->{$vhost}->{vhostAuthnLevel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | $class->tsv->{serviceTokenTTL}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 80 | $conf->{vhostOptions}->{$vhost}->{vhostServiceTokenTTL}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | $class->tsv->{accessToTrace}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 80 | $conf->{vhostOptions}->{$vhost}->{vhostAccessToTrace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $class->tsv->{devOpsRulesUrl}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 80 | $conf->{vhostOptions}->{$vhost}->{vhostDevOpsRulesUrl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 50 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ## @imethod protected void portalInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # Verify that portal variable exists. Die unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub portalInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
portalInit: called CC=3 SCAR=12.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 49 | ▶ | unless ( $conf->{portal} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $class->logger->error("portal parameter required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 49 | ▶ | if ( $conf->{portal} =~ /[\$\(&\|"']/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ( $class->tsv->{portal} ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $class->conditionSub( $conf->{portal} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 49 | ▶ | $class->tsv->{portal} = sub { return $conf->{portal} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 49 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ## @imethod void locationRulesInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Compile rules. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Rules are stored in $args->{locationRules}->{<virtualhost>} that contains | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # regexp=>test expressions where : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # - regexp is used to test URIs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # - test contains an expression used to grant the user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # This function creates 2 hashRef containing : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # - one list of the compiled regular expressions for each virtual host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # - one list of the compiled functions (compiled with conditionSub()) for each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # virtual host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | sub locationRulesInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 50 | ▶ | my ( $class, $conf, $orules ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locationRulesInit: called CC=23 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 50 | ▶ | $orules ||= $conf->{locationRules}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$orules ||= $conf->{"locationRules"}
MC/DC0%0/2
$orules ||= $conf->{"locationRules"}
$orules
$conf->{"locationRules"}
Truth table66%2/3
A ||= B
A= $orulesB= $conf->{"locationRules"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 50 | $class->tsv->{vhostReg} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 50 | my @lastReg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 50 | foreach my $vhost ( keys %$orules ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 325 | my $rules = $orules->{$vhost}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 325 | ▶ | if ( $vhost =~ /[\%\*]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | my $expr = join '[^\.]*', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 160 | my $elt = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 200 | join '.*', map { quotemeta $_ } split /\*/, $elt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } split /\%/, $vhost; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 160 | ▶ | if ($expr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 160 | push @{ $class->tsv->{vhostReg} }, [ qr/^$expr$/, $vhost ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | push @lastReg, [ qr/.+/, $vhost ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 325 | $class->tsv->{locationCount}->{$vhost} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 325 | $class->tsv->{locationCondition}->{$vhost} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 325 | $class->tsv->{locationProtection}->{$vhost} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 325 | $class->tsv->{locationRegexp}->{$vhost} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 325 | $class->tsv->{locationConditionText}->{$vhost} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 325 | $class->tsv->{locationAuthnLevel}->{$vhost} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 325 | foreach my $url ( sort keys %{$rules} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 987 | my ( $cond, $prot ) = $class->conditionSub( $rules->{$url} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 987 | ▶ | unless ($cond) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $class->tsv->{maintenance}->{$vhost} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $class->logger->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | "Unable to build rule '$rules->{$url}': " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | . $class->tsv->{jail}->error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 987 | ▶ | if ( $url eq 'default' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 325 | $class->tsv->{defaultCondition}->{$vhost} = $cond; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 325 | $class->tsv->{defaultProtection}->{$vhost} = $prot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 662 | push @{ $class->tsv->{locationCondition}->{$vhost} }, $cond; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 662 | push @{ $class->tsv->{locationProtection}->{$vhost} }, $prot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 662 | push @{ $class->tsv->{locationRegexp}->{$vhost} }, qr/$url/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 662 | ▶ | push @{ $class->tsv->{locationAuthnLevel}->{$vhost} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $url =~ /\(\?#AuthnLevel=(-?\d+)\)/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 662 | ▶ | push @{ $class->tsv->{locationConditionText}->{$vhost} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | $url =~ /^\(\?#(.*?)\)/ ? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | : $url =~ /^(.*?)##(.+)$/ ? $2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | : $url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 662 | $class->tsv->{locationCount}->{$vhost}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # Default policy set to 'accept' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 325 | ▶ | unless ( $class->tsv->{defaultCondition}->{$vhost} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $class->tsv->{defaultCondition}->{$vhost} = sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $class->tsv->{defaultProtection}->{$vhost} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 40 | @{ $class->tsv->{vhostReg} } = sort { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 189 | my $av = $a->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 189 | my $bv = $b->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 189 | ▶ | return 1 if $av =~ /^\*/ and $bv !~ /^\*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$av =~ /^\*/ and not $bv =~ /^\*/
MC/DC50%1/2
$av =~ /^\*/ and not $bv =~ /^\*/
$av =~ /^\*/
not $bv =~ /^\*/
Truth table66%2/3
A and not(B)
A= $av =~ /^\*/B= not $bv =~ /^\*/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 152 | ▶ | return -1 if $bv =~ /^\*/ and $av !~ /^\*/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$bv =~ /^\*/ and not $av =~ /^\*/
MC/DC50%1/2
$bv =~ /^\*/ and not $av =~ /^\*/
$bv =~ /^\*/
not $av =~ /^\*/
Truth table66%2/3
A and not(B)
A= $bv =~ /^\*/B= not $av =~ /^\*/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 106 | ▶ | return 1 if $av =~ /^\%/ and $bv !~ /^\%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$av =~ /^\%/ and not $bv =~ /^\%/
MC/DC0%0/2
$av =~ /^\%/ and not $bv =~ /^\%/
$av =~ /^\%/
not $bv =~ /^\%/
Truth table33%1/3
A and not(B)
A= $av =~ /^\%/B= not $bv =~ /^\%/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 106 | ▶ | return -1 if $bv =~ /^\%/ and $av !~ /^\%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$bv =~ /^\%/ and not $av =~ /^\%/
MC/DC0%0/2
$bv =~ /^\%/ and not $av =~ /^\%/
$bv =~ /^\%/
not $av =~ /^\%/
Truth table33%1/3
A and not(B)
A= $bv =~ /^\%/B= not $av =~ /^\%/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 106 | ▶ | return length($bv) <=> length($av) || $av cmp $bv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
length $bv <=> length $av || $av cmp $bv
MC/DC0%0/2
length $bv <=> length $av || $av cmp $bv
length $bv <=> length $av
$av cmp $bv
Truth table33%1/3
A || B
A= length $bv <=> length $avB= $av cmp $bv
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 50 | ▶ | } @{ $class->tsv->{vhostReg} } if @{ $class->tsv->{vhostReg} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 50 | ▶ | push @{ $class->tsv->{vhostReg} }, @lastReg if @lastReg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 50 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ## @imethod protected void sessionStorageInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # Initialize the Apache::Session::* module choosed to share user's variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # and the Cache::Cache module chosen to cache sessions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | sub sessionStorageInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sessionStorageInit: called CC=10 SCAR=35.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # Global session storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 49 | ▶ | unless ( $class->tsv->{sessionStorageModule} = $conf->{globalStorage} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $class->logger->error("globalStorage required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 23 | ▶ | eval "use " . $class->tsv->{sessionStorageModule}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 49 | ▶ | die($@) if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 49 | $class->tsv->{sessionStorageOptions} = $conf->{globalStorageOptions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # OIDC session storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 49 | ▶ | if ( $conf->{oidcStorage} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | eval "use " . $conf->{oidcStorage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | die($@) if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $class->tsv->{oidcStorageModule} = $conf->{oidcStorage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $class->tsv->{oidcStorageOptions} = $conf->{oidcStorageOptions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 49 | $class->tsv->{oidcStorageModule} = $conf->{globalStorage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 49 | $class->tsv->{oidcStorageOptions} = $conf->{globalStorageOptions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # Local session storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 49 | ▶ | if ( $conf->{localSessionStorage} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $class->tsv->{sessionCacheModule} = $conf->{localSessionStorage}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | $class->tsv->{sessionCacheOptions} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $conf->{localSessionStorageOptions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $class->tsv->{sessionCacheOptions}->{default_expires_in} ||= 600; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$class->tsv->{"sessionCacheOptions"}{"default_expires_in"} ||= 600
MC/DC0%0/1
$class->tsv->{"sessionCacheOptions"}{"default_expires_in"} ||= 600
$class->tsv->{"sessionCacheOptions"}{"default_expires_in"}
Truth table0%0/2
A
A= $class->tsv->{"sessionCacheOptions"}{"default_expires_in"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ( $conf->{status} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $params = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if ( $class->tsv->{sessionCacheModule} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | $params = $class->tsv->{sessionCacheModule} . ',{' . join( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ',', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | "$_ => '" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | . $class->tsv->{sessionCacheOptions}->{$_} . "'" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | keys %{ $class->tsv->{sessionCacheOptions} // {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$class->tsv->{"sessionCacheOptions"} // {}
MC/DC0%0/1
$class->tsv->{"sessionCacheOptions"} // {}
$class->tsv->{"sessionCacheOptions"}
Truth table0%0/2
A
A= $class->tsv->{"sessionCacheOptions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ) . '}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 49 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ## @imethod void headersInit(hashRef args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # Create the subroutines used to insert headers into the HTTP request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # @param $args reference to the configuration hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | sub headersInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 50 | ▶ | my ( $class, $conf, $headers ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headersInit: called CC=8 SCAR=21.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 50 | ▶ | $headers ||= $conf->{exportedHeaders}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$headers ||= $conf->{"exportedHeaders"}
MC/DC100%2/2
$headers ||= $conf->{"exportedHeaders"}
$headers
$conf->{"exportedHeaders"}
Truth table100%3/3
A ||= B
A= $headersB= $conf->{"exportedHeaders"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # Creation of the subroutine which will generate headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 50 | foreach my $vhost ( keys %{$headers} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 102 | ▶ | unless ($vhost) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $class->logger->warn('Empty vhost in headers, skipping'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 102 | ▶ | $headers->{$vhost} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$headers->{$vhost} ||= {}
MC/DC0%0/1
$headers->{$vhost} ||= {}
$headers->{$vhost}
Truth table50%1/2
A
A= $headers->{$vhost}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 102 | my %headers = %{ $headers->{$vhost} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 102 | $class->tsv->{headerList}->{$vhost} = [ keys %headers ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 102 | my $sub = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 102 | foreach ( keys %headers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 120 | ▶ | $headers{$_} ||= "''"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$headers{$_} ||= "''"
MC/DC100%1/1
$headers{$_} ||= "''"
$headers{$_}
Truth table100%2/2
A
A= $headers{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 120 | my $val = $class->substitute( $headers{$_} ) . " // ''"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 120 | $sub .= "('$_' => $val),"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 102 | ▶ | unless ( $class->tsv->{forgeHeaders}->{$vhost} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $class->buildSub($sub) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $class->tsv->{maintenance}->{$vhost} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $class->logger->error( "$class Unable to forge $vhost headers: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | . $class->tsv->{jail}->error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 50 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ## @imethod protected void postUrlInit() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # Prepare methods to post form attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | sub postUrlInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
postUrlInit: called CC=9 SCAR=38.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 49 | ▶ | return unless ( $conf->{post} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # Browse all vhost | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | foreach my $vhost ( keys %{ $conf->{post} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Browse all POST URI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | foreach my $url ( keys %{ $conf->{post}->{$vhost} || {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $d = $conf->{post}->{$vhost}->{$url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $class->logger->debug("Compiling POST data for $url"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # Where to POST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | $d->{target} ||= $url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$d->{"target"} ||= $url
MC/DC0%0/2
$d->{"target"} ||= $url
$d->{"target"}
$url
Truth table0%0/3
A ||= B
A= $d->{"target"}B= $url
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | $d->{vars} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$d->{"vars"} ||= []
MC/DC0%0/1
$d->{"vars"} ||= []
$d->{"vars"}
Truth table0%0/2
A
A= $d->{"vars"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | foreach my $input ( @{ delete $d->{vars} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $sub .= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | "'$input->[0]' => " . $class->substitute( $input->[1] ) . ","; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | $class->tsv->{inputPostData}->{$vhost}->{ delete $d->{target} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | = $class->tsv->{outputPostData}->{$vhost}->{$url} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | $class->buildSub($sub) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $class->tsv->{maintenance}->{$vhost} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | $class->logger->error( "$class: Unable to build post data: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | . $class->tsv->{jail}->error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $class->tsv->{postFormParams}->{$vhost}->{$url} = $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | ## @imethod protected codeRef conditionSub(string cond) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # Returns a compiled function used to grant users (used by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # locationRulesInit(). The second value returned is a non null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # constant if URL is not protected (by "unprotect" or "skip"), 0 else. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # @param $cond The boolean expression to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # @param $mainClass optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # @return array (ref(sub), int) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | sub conditionSub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 987 | ▶ | my ( $class, $cond ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conditionSub: called CC=11 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 987 | $cond =~ s/\(\?#(\d+)\)$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 987 | ▶ | my ( $OK, $NOK ) = ( sub { 1 }, sub { 0 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # Simple cases : accept and deny | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 987 | ▶ | return ( $OK, 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | if ( $cond =~ /^accept$/i ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 616 | ▶ | return ( $NOK, 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | if ( $cond =~ /^deny$/i ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # Cases unprotect and skip : 2nd value is 1 or 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 487 | ▶ | return ( $OK, UNPROTECT ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | if ( $cond =~ /^unprotect$/i ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 487 | ▶ | return ( $OK, SKIP ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | if ( $cond =~ /^skip$/i ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # Case logout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 487 | ▶ | if ( $cond =~ /^logout(?:_sso)?(?:\s+(.*))?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 80 | my $url = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my ( $req, $session ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $session->{_logout} = $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | my ( $req, $session ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $session->{_logout} = $class->tsv->{portal}->($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 80 | ▶ | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # logout_app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 407 | ▶ | if ( $cond =~ /^logout_app(?:\s+(.*))?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | return $class->logout_app($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # logout_app_sso | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | elsif ( $cond =~ /^logout_app_sso(?:\s+(.*))?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return $class->logout_app_sso($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 407 | my $mayskip = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 407 | ▶ | $mayskip = MAYSKIP if $cond =~ /\bskip\b/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # Replace some strings in condition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 407 | $cond = $class->substitute($cond); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 407 | my $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 407 | ▶ | unless ( $sub = $class->buildSub($cond) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | $class->logger->error( "$class: Unable to build condition ($cond): " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | . $class->tsv->{jail}->error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # Return sub and protected flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 407 | return ( $sub, $mayskip ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ## These methods should be overriden in subclasses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | sub logout_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | return ( sub { 1 }, 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
logout_app: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | sub logout_app_sso { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | return ( sub { 1 }, 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
logout_app_sso: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | ## @method arrayref aliasInit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # @param options vhostOptions configuration item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # @return arrayref of vhost and aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | sub aliasInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aliasInit: called CC=5 SCAR=17.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 49 | delete $class->tsv->{vhostAlias}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 49 | ▶ | foreach my $vhost ( keys %{ $conf->{vhostOptions} || {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 79 | ▶ | if ( my $aliases = $conf->{vhostOptions}->{$vhost}->{vhostAliases} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | foreach ( split /\s+/, $aliases ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $class->tsv->{vhostAlias}->{$_} = $vhost; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $class->logger->debug("Registering $_ as alias of $vhost"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 49 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # TODO: support wildcards in aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | ## @method arrayref oauth2Init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # @param options vhostOptions configuration item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # @return arrayref of vhost and aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | sub oauth2Init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oauth2Init: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 49 | ▶ | foreach my $rp ( keys %{ $conf->{oidcRPMetaDataOptions} || {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 4 | ▶ | if ( $conf->{oidcRPMetaDataOptions}->{$rp} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$conf->{"oidcRPMetaDataOptions"}{$rp} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsClientID"}
MC/DC0%0/2
$conf->{"oidcRPMetaDataOptions"}{$rp} and $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsClientID"}
$conf->{"oidcRPMetaDataOptions"}{$rp}
$conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsClientID"}
Truth table33%1/3
A and B
A= $conf->{"oidcRPMetaDataOptions"}{$rp}B= $conf->{"oidcRPMetaDataOptions"}{$rp}{"oidcRPMetaDataOptionsClientID"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | and $conf->{oidcRPMetaDataOptions}->{$rp} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ->{oidcRPMetaDataOptionsClientID} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | $class->tsv->{oauth2Options}->{$rp}->{clientId} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | $conf->{oidcRPMetaDataOptions}->{$rp} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 4 | ->{oidcRPMetaDataOptionsClientID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 49 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | sub msgBrokerInit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 49 | ▶ | my ( $class, $conf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
msgBrokerInit: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 49 | ▶ | my $brokerClass = $conf->{messageBroker} || '::NoBroker'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'messageBroker'} || '::NoBroker'
MC/DC0%0/1
$conf->{'messageBroker'} || '::NoBroker'
$conf->{'messageBroker'}
Truth table50%1/2
A
A= $conf->{'messageBroker'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 49 | $brokerClass =~ s/^::/Lemonldap::NG::Common::MessageBroker::/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 49 | eval "require $brokerClass"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 49 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 49 | $class->tsv->{msgBrokerReader} = $brokerClass->new( $conf, $class->logger ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 49 | $class->tsv->{msgBrokerReader}->subscribe( $conf->{eventQueueName} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 49 | $class->tsv->{msgBrokerWriter} = $brokerClass->new( $conf, $class->logger ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | sub substitute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 554 | ▶ | my ( $class, $expr ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
substitute: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 554 | ▶ | $expr //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$expr //= ""
MC/DC100%1/1
$expr //= ""
$expr
Truth table100%2/2
A
A= $expr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # substitute special vars, just for retro-compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 554 | $expr =~ s/\$date\b/&date/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 554 | $expr =~ s/\$vhost\b/\$ENV{HTTP_HOST}/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 554 | $expr =~ s/\$ip\b/\$ENV{REMOTE_ADDR}/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | # substitute vars with session data, excepts special vars $_ and $\d+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 554 | $expr =~ s/\$(?!(?:ENV|env)\b)(_\w+|[a-zA-Z]\w*)/\$s->{$1}/sg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 554 | $expr =~ s/\$ENV\{/\$r->{env}->\{/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 554 | $expr =~ s/\$env->\{/\$r->{env}->\{/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 554 | $expr =~ s/\bskip\b/q\{999_SKIP\}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # handle inGroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 554 | $expr =~ s/\binGroup\(([^)]*)\)/listMatch(\$s->{'hGroups'},$1,1)/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # handle has2f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 554 | $expr =~ s/\bhas2f\(([^),]*)\)/has2f_internal(\$s,$1)/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # handle inSubnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 554 | $expr =~ s/\binSubnet\(([^)]*)\)/ipInSubnet(\$r->{env}->{REMOTE_ADDR},$1)/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # handle inSubnet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 554 | $expr =~ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | s/\binDomain\(([^)]*)\)/inDomain_internal(\$r->{env}->{HTTP_HOST},$1)/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 554 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | sub buildSub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 536 | ▶ | my ( $class, $val ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
buildSub: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | my $res = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 536 | $class->tsv->{jail}->jail_reval("sub{my (\$r,\$s)=\@_; local *_;return($val)}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 536 | ▶ | unless ($res) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $class->logger->error( $class->tsv->{jail}->error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 536 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||