| 1 | package Lemonldap::NG::Handler::Lib::PSGI; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | #use Lemonldap::NG::Handler::Main qw(:jailSharedVars); | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 23 | our $VERSION = '2.23.0'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 23 | has protection => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 23 | has rule => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 23 | has api => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | ## @method boolean init($args) | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # Initalize main handler | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 45 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=11 SCAR=28.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 45 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 45 | eval { $self->api->init($args) }; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 45 | ▶ | if ( $@ and not( $args->{protection} and $args->{protection} eq 'none' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$@ and not $args->{"protection"} && $args->{"protection"} eq "none"
$args->{'protection'} && $args->{'protection'} eq 'none'
MC/DC0%0/3
$@ and not $args->{"protection"} && $args->{"protection"} eq "none"
$@
$args->{'protection'}
$args->{'protection'} eq 'none'
Truth table25%1/4
A and not(B && C)
A= $@B= $args->{'protection'}C= $args->{'protection'} eq 'none'
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $self->error($@); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 45 | ▶ | unless ( $self->api->checkConf($self) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->api->checkConf($self) or $args->{"protection"} and $args->{"protection"} eq "none"
$args->{"protection"} and $args->{"protection"} eq "none"
MC/DC33%1/3
$self->api->checkConf($self) or $args->{"protection"} and $args->{"protection"} eq "none"
$self->api->checkConf($self)
$args->{"protection"}
$args->{"protection"} eq "none"
Truth table50%2/4
A or B and C
A= $self->api->checkConf($self)B= $args->{"protection"}C= $args->{"protection"} eq "none"
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | or ( $args->{protection} and $args->{protection} eq 'none' ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | $self->error( | |||||||||||||||||||||||||||||||||||||||||
| 27 | "Unable to protect this server ($Lemonldap::NG::Common::Conf::msg)" | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 43 | eval { $self->portal( $self->api->tsv->{portal}->() ) }; | |||||||||||||||||||||||||||||||||||||||||
| 33 | my $rule = | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 43 | ▶ | $args->{protection} || $self->api->localConfig->{protection} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$args->{'protection'} || $self->api->localConfig->{'protection'} || ''
$args->{"protection"} or $self->api->localConfig->{"protection"}
MC/DC50%1/2
$args->{'protection'} || $self->api->localConfig->{'protection'} || ''
$args->{"protection"}
$self->api->localConfig->{"protection"}
Truth table66%2/3
A or B
A= $args->{"protection"}B= $self->api->localConfig->{"protection"}
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 43 | ▶ | $self->rule( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | $rule eq 'authenticate' ? 1 : $rule eq 'manager' ? '' : $rule ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 43 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | ## @methodi void _run() | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # Check if protecton is activated then return a code ref that will launch | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # _authAndTrace() if protection in on or handler() else | ||||||||||||||||||||||||||||||||||||||||||
| 43 | #@return code-ref | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 10 | ▶ | sub _run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # Override _run() only if protection != 'none' | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | ▶ | if ( !$self->rule or $self->rule ne 'none' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->rule or $self->rule ne "none"
MC/DC50%1/2
not $self->rule or $self->rule ne "none"
not $self->rule
$self->rule ne "none"
Truth table66%2/3
not(A) or B
A= not $self->ruleB= $self->rule ne "none"
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 9 | $self->logger->debug('PSGI app is protected'); | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # Handle requests | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # Developers, be careful: Only this part is executed at each request | ||||||||||||||||||||||||||||||||||||||||||
| 53 | return $self->psgiAdapter( | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 51 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 51 | return $self->_authAndTrace( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | $self->logger->debug('PSGI app is not protected'); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | # Check if main handler initialization has been done | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | unless ( $self->api->tsv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->logger->debug('Checking conf'); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | eval { $self->api->checkConf() }; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $self->logger->error($@) if ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # Handle unprotected requests | ||||||||||||||||||||||||||||||||||||||||||
| 71 | return $self->psgiAdapter( | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $req = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $res = $self->handler($req); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | push @{ $res->[1] }, $req->spliceHdrs; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 22 | ▶ | sub reload { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 22 | my ( $class, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 22 | ▶ | $args //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args //= {}
MC/DC0%0/1
$args //= {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 22 | my $self = $class->new($args); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 22 | $self->init($args); | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # Check if main handler initialization has been done | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 22 | ▶ | unless ( %{ $self->api->tsv } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | eval { $self->api->checkConf() }; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | $self->logger->error($@) if ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | return $self->psgiAdapter( | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my $req = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $self->api->reload($req); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | return [ 200, [ $req->spliceHdrs ], [ $req->{respBody} ] ]; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 22 | ); | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | ## @method private PSGI-Response _authAndTrace($req) | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # Launch $self->api::run() and then handler() if | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # response is 200. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 162 | ▶ | sub _authAndTrace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_authAndTrace: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 162 | my ( $self, $req, $noCall ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 162 | ▶ | unless ( eval { $self->api->tsv->{portal} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | $self->api->checkConf(1); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # TODO: handle types | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 162 | my $type = $self->api->checkType($req); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 162 | ▶ | if ( my $t = $req->env->{VHOSTTYPE} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 44 | $type = $t; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 162 | my $tmp = $self->api; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 162 | $tmp =~ s/::\w+$/::/; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 162 | $type = $tmp . $type; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 162 | Lemonldap::NG::Handler::Main->buildAndLoadType($type); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 162 | ▶ | die $@ if ($@); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 162 | my ( $res, $session ) = $type->run( $req, $self->{rule} ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 162 | my $portal = eval { $type->tsv->{portal}->($req) }; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 162 | ▶ | $self->logger->warn($@) if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 162 | ▶ | if ( $res < 300 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 61 | ▶ | if ($noCall) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | return [ $res, [ $req->spliceHdrs ], [] ]; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 59 | $self->logger->debug('User authenticated, calling handler()'); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 59 | $res = $self->handler($req); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 59 | push @{ $res->[1] }, $req->spliceHdrs; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 59 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | elsif ( $res < 400 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 48 | return [ $res, [ $req->spliceHdrs ], [] ]; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 53 | ▶ | my $s = ( $portal ? $portal . "/lmerror/$res" : '' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 53 | $s = | |||||||||||||||||||||||||||||||||||||||||
| 142 | '<html><head><title>Redirection</title></head><body>' | ||||||||||||||||||||||||||||||||||||||||||
| 143 | . qq{<script type="text/javascript">window.location='$s'</script>} | ||||||||||||||||||||||||||||||||||||||||||
| 144 | . '<h1>Please wait</h1>' | ||||||||||||||||||||||||||||||||||||||||||
| 145 | . qq{<p>An error occurs, you're going to be redirected to <a href="$s">$s</a>.</p>} | ||||||||||||||||||||||||||||||||||||||||||
| 146 | . '</body></html>'; | ||||||||||||||||||||||||||||||||||||||||||
| 147 | return [ | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 53 | $res, | |||||||||||||||||||||||||||||||||||||||||
| 149 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 150 | $req->spliceHdrs, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 'Content-Type' => 'text/html', | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 'Content-Length' => length $s | ||||||||||||||||||||||||||||||||||||||||||
| 153 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 154 | [$s] | ||||||||||||||||||||||||||||||||||||||||||
| 155 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | ## @method hashRef user() | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # @return hash of user data | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | return $req->userData | ||||||||||||||||||||||||||||||||||||||||||
| 164 | || { $Lemonldap::NG::Handler::Main::tsv->{whatToTrace} | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | || _whatToTrace => 'anonymous' }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$req->userData || {$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace', 'anonymous'}
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace'
MC/DC0%0/1
$req->userData || {$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace', 'anonymous'}
$req->userData
MC/DC0%0/1
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace'
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'}
Truth table0%0/2
A
A= $req->userData
Truth table0%0/2
A
A= $Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'}
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | ## @method hashRef custom() | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # @return hash of custom data | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub custom { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | return { $Lemonldap::NG::Handler::Main::tsv->{customToTrace} }; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | ## @method string userId() | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # @return user identifier to log | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | sub userId { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
userId: called CC=4 SCAR=15.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | my ( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 179 | my $userId = | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $req->userData->{ $Lemonldap::NG::Handler::Main::tsv->{whatToTrace} | ||||||||||||||||||||||||||||||||||||||||||
| 181 | || '_whatToTrace' } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | || $req->userData->{'_user'} # Fix 2377 | ||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
$req->userData->{$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} or '_whatToTrace'} || $req->userData->{'_user'} || 'anonymous'
$req->userData->{$Lemonldap::NG::Handler::Main::tsv->{"whatToTrace"} or "_whatToTrace"} or $req->userData->{"_user"}
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace'
MC/DC0%0/2
$req->userData->{$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} or '_whatToTrace'} || $req->userData->{'_user'} || 'anonymous'
$req->userData->{$Lemonldap::NG::Handler::Main::tsv->{"whatToTrace"} or "_whatToTrace"}
$req->userData->{"_user"}
MC/DC0%0/1
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'} || '_whatToTrace'
$Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'}
Truth table33%1/3
A or B
A= $req->userData->{$Lemonldap::NG::Handler::Main::tsv->{"whatToTrace"} or "_whatToTrace"}B= $req->userData->{"_user"}
Truth table50%1/2
A
A= $Lemonldap::NG::Handler::Main::tsv->{'whatToTrace'}
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | || 'anonymous'; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $self->logger->debug("Returned userId: $userId"); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return $userId; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | ## @method boolean group(string group) | ||||||||||||||||||||||||||||||||||||||||||
| 190 | # @param $group name of the Lemonldap::NG group to test | ||||||||||||||||||||||||||||||||||||||||||
| 191 | # @return boolean : true if user is in this group | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
group: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my ( $self, $req, $group ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | return () unless ( $req->userData->{groups} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return ( $req->userData->{groups} =~ /\b$group\b/ ); | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | ## @method PSGI::Response sendError($req,$err,$code) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # Add user id to $err before calling Lemonldap::NG::Common::PSGI::sendError() | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # @param $req Lemonldap::NG::Common::PSGI::Request | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # @param $err String to push | ||||||||||||||||||||||||||||||||||||||||||
| 202 | # @code int HTTP error code (default to 500) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | sub sendError { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendError: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | my ( $self, $req, $err, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | $err ||= $req->error; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$err ||= $req->error
MC/DC0%0/2
$err ||= $req->error
$err
$req->error
Truth table33%1/3
A ||= B
A= $errB= $req->error
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | $self->logger->warn( '[' . $self->userId($req) . "] $err" ); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | return $self->Lemonldap::NG::Common::PSGI::sendError( $req, $err, $code ); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||