blib/lib/Lemonldap/NG/Portal/Main/Display.pm

filter: Statementstmt 61.2% 158 / 258 Branchbran 54.1% 92 / 170 Conditioncond 46.5% 88 / 189 MC/DCmcdc 18.5% 18 / 97 Subroutinesub 87.5% 21 / 24 Podpod 0.0% 0 / 11 totaltotal 50.3% 377 / 749 CC 164 SCAR 63.4
CC
164
Cov
55%
display
938.8
mkOidcConsent
90.0
displayInit
48.7
CRAP 567.5
« blib/lib/Lemonldap/NG/Portal/Lib/Net/LDAP.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/CheckDevOps.pm »
1 ## @file
2 # Display functions for LemonLDAP::NG Portal
3 package Lemonldap::NG::Portal::Main::Display;
4  
5 454 our $VERSION = '2.23.4';
6  
7 package Lemonldap::NG::Portal::Main;
8 454 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 454 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 454 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 454 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 454 has speChars => ( is => 'rw' );
14 454 has skinRules => ( is => 'rw' );
15 496 ▶has stayConnected => ( is => 'rw', default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
16 496 ▶has requireOldPwd => ( is => 'rw', default => sub { 1 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
17 496 ▶has rememberAuthChoice => ( is => 'rw', default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
18 496 ▶has passwordPolicyActivation => ( is => 'rw', default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
19 has passwordResetUrl => (
20 is => 'ro',
21 lazy => 1,
22 136 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
23 136 ▶ $_[0]->conf->{mailUrl} || $_[0]->buildUrl("resetpwd");
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->conf->{"mailUrl"} or $_[0]->buildUrl("resetpwd") 0 136 136
24 }
25 454 );
26 has certificateResetUrl => (
27 is => 'ro',
28 lazy => 1,
29 136 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
30 $_[0]->conf->{certificateResetByMailURL}
31 136 ▶ || $_[0]->buildUrl("certificateReset");
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->conf->{"certificateResetByMailURL"} or $_[0]->buildUrl("certificateReset") 0 136 136
32 }
33 454 );
34 has registerUrl => (
35 is => 'ro',
36 lazy => 1,
37 136 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
38 136 ▶ $_[0]->conf->{registerUrl} || $_[0]->buildUrl("register");
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->conf->{"registerUrl"} or $_[0]->buildUrl("register") 0 136 136
39 }
40 454 );
41 has ott => (
42 is => 'rw',
43 lazy => 1,
44 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 my $ott = $_[0]->loadModule('::Lib::OneTimeToken');
46 0 $ott->timeout( $_[0]->conf->{formTimeout} );
47 0 return $ott;
48 }
49 454 );
50  
51 671 ▶sub displayInit {
Subroutine displayInit: called CC=14 SCAR=38.9
Pod undocumented
52 671 my ($self) = @_;
53 671 $self->skinRules( [] );
54 671 ▶ if ( $self->conf->{portalSkinRules} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{"portalSkinRules"}) 0 671 671
55 0 foreach my $skinRule ( sort keys %{ $self->conf->{portalSkinRules} } ) {
56 0 my $sub = HANDLER->buildSub( HANDLER->substitute($skinRule) );
57 0 ▶ if ($sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub) { } 0 0 0
58 0 push @{ $self->skinRules },
59 0 [ $self->conf->{portalSkinRules}->{$skinRule}, $sub ];
60 }
61 else {
62 $self->logger->error(
63 qq(Skin rule "$skinRule" returns an error: )
64 . HANDLER->tsv->{jail}->error
65 0 ▶ || 'Unable to compile rule' );
Condition0%0/2
qq[Skin rule "$skinRule" returns an error: ] . 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
l!l
00
MC/DC0%0/1
qq[Skin rule "$skinRule" returns an error: ] . 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
qq[Skin rule "$skinRule" returns an error: ] . 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Truth table0%0/2
A
A= qq[Skin rule "$skinRule" returns an error: ] . 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Aresult
11
00
66 }
67 }
68 }
69  
70 my $rule = HANDLER->buildSub(
71 671 HANDLER->substitute( $self->conf->{portalRequireOldPassword} ) );
72 671 ▶ unless ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rule) 0 671 671
73 0 ▶ my $error = HANDLER->tsv->{jail}->error || 'Unable to compile rule';
Condition0%0/2
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
l!l
00
MC/DC0%0/1
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Truth table0%0/2
A
A= 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Aresult
11
00
74 0 $self->logger->error("Bad requireOldPwd rule: $error");
75 }
76 671 $self->requireOldPwd($rule);
77  
78 $rule =
79 671 HANDLER->buildSub( HANDLER->substitute( $self->conf->{stayConnected} ) );
80 671 ▶ unless ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rule) 0 671 671
81 0 ▶ my $error = HANDLER->tsv->{jail}->error || 'Unable to compile rule';
Condition0%0/2
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
l!l
00
MC/DC0%0/1
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Truth table0%0/2
A
A= 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Aresult
11
00
82 0 $self->logger->error("Bad stayConnected rule: $error");
83 }
84 671 $self->stayConnected($rule);
85  
86 $rule =
87 HANDLER->buildSub(
88 671 HANDLER->substitute( $self->conf->{passwordPolicyActivation} ) );
89 671 ▶ unless ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rule) 0 671 671
90 0 ▶ my $error = HANDLER->tsv->{jail}->error || 'Unable to compile rule';
Condition0%0/2
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
l!l
00
MC/DC0%0/1
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Truth table0%0/2
A
A= 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Aresult
11
00
91 0 $self->logger->error("Bad passwordPolicyActivation rule: $error");
92 }
93 671 $self->passwordPolicyActivation($rule);
94  
95 $rule =
96 HANDLER->buildSub(
97 671 HANDLER->substitute( $self->conf->{rememberAuthChoiceRule} ) );
98 671 ▶ unless ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rule) 0 671 671
99 0 ▶ my $error = HANDLER->tsv->{jail}->error || 'Unable to compile rule';
Condition0%0/2
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
l!l
00
MC/DC0%0/1
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error || 'Unable to compile rule'
'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Truth table0%0/2
A
A= 'Lemonldap::NG::Handler::PSGI::Main'->tsv->{'jail'}->error
Aresult
11
00
100 0 $self->logger->error("Bad rememberAuthChoiceRule rule: $error");
101 }
102 671 $self->rememberAuthChoice($rule);
103  
104 my %speChars = $self->conf->{passwordPolicySpecialChar} eq '__ALL__'
105 ? () # Dedup
106 12 : map { ( s/\s+/<space>/r => 1 ) } split '',
107 671 ▶ $self->conf->{passwordPolicySpecialChar};
Branch: 1 branch
BranchTrueFalseTotal
$self->conf->{'passwordPolicySpecialChar'} eq '__ALL__' ? : 669 2 671
108 671 $self->speChars( join q{ }, sort keys %speChars );
109 }
110  
111 330 ▶sub isPP {
Subroutine isPP: called CC=3 SCAR=13.1
Pod undocumented
112 330 my $self = shift;
113 330 my $ppRules = $self->getPpolicyRules();
114 330 foreach (@$ppRules) {
115 0 ▶ return 1 if $_->{'condition'};
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"condition"} 0 0 0
116 }
117 330 return 0;
118 }
119  
120 # Call portal process and set template parameters
121 # @return template name and template parameters
122 396 ▶sub display {
Subroutine display: called CC=111 SCAR=68.4
Pod undocumented
123 396 my ( $self, $req ) = @_;
124  
125 396 my $skin_dir = $self->conf->{templateDir};
126 396 my ( $skinfile, %templateParams );
127  
128 # 1. Authentication not complete
129  
130 # 1.1 A notification has to be done (session is created but hidden and
131 # unusable until the user has accept the message)
132 396 ▶ if ( my $notif = $req->data->{notification} ) {
Branch: 12 branches
BranchTrueFalseTotal
if (my $notif = $req->data->{'notification'}) { } 0 396 396
elsif ($req->{'error'} == 42) { } 1 395 396
elsif ($req->{'error'} == -5) { } 3 392 395
elsif (my $info = $req->info) { } 14 378 392
elsif ($req->{'error'} == 62 or $req->{'error'} == 63) { } 0 378 378
elsif ($req->{'error'} == -2) { } 0 378 378
elsif ($req->{'error'} == -6) { } 1 377 378
elsif ($req->error == 0 or $req->error == 113) { } 12 365 377
elsif ($req->error == 102) { } 0 365 365
elsif ($req->error == 85) { } 0 365 365
elsif ($req->error == 87) { } 0 365 365
elsif ($req->noLoginDisplay or not $req->data->{'noerror'} and $req->userData and %{$req->userData;} or $self->conf->{'authentication'} eq 'Combination' and $req->{'error'} > 0 and $req->{'error'} != 9 and $req->{'error'} != 5 and $req->{'error'} != 25 and $req->{'error'} != 22 and $req->{'error'} != 39 and $req->{'error'} != 112) { } 47 318 365
133 0 $self->logger->debug('Display: notification detected');
134 0 $skinfile = 'notification';
135 %templateParams = (
136 $self->getErrorTplParams($req),
137 FORM_ACTION => $self->relativeUrl( $req, 'notifback' ),
138 NOTIFICATION => $notif,
139 HIDDEN_INPUTS => $self->buildHiddenForm($req),
140 AUTH_URL => $req->{data}->{_url},
141 CHOICE_PARAM => $self->conf->{authChoiceParam},
142 CHOICE_VALUE => $req->data->{_authChoice},
143 (
144 $req->data->{customScript}
145 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
146 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
147 ),
148 );
149 }
150  
151 # 1.2a An authentication (or userDB) module needs to ask a question
152 # before processing to the request
153 elsif ( $req->{error} == PE_CONFIRM ) {
154 1 $self->logger->debug('Display: confirm detected');
155 1 $skinfile = 'confirm';
156 %templateParams = (
157 $self->getErrorTplParams($req),
158 AUTH_URL => $req->{data}->{_url},
159 MSG => $req->info,
160 HIDDEN_INPUTS => $self->buildHiddenForm($req),
161 ACTIVE_TIMER => $req->data->{activeTimer},
162 FORM_ACTION => $req->data->{confirmFormAction}
163 || "#",
164 FORM_METHOD => $self->conf->{confirmFormMethod},
165 CHOICE_PARAM => $self->conf->{authChoiceParam},
166 CHOICE_VALUE => $req->data->{_authChoice},
167 CHECK_LOGINS => $self->conf->{portalCheckLogins}
168 && $req->data->{login},
169 ASK_LOGINS => scalar $req->param('checkLogins')
170 || 0,
171 ASK_STAYCONNECTED => scalar $req->param('stayconnected')
172 || 0,
173 CONFIRMKEY => $self->stamp(),
174 (
175 $req->data->{customScript}
176 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
177 1 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 1 1
Condition44%4/9
$req->data->{'confirmFormAction'} || '#'
l!l
01
$self->conf->{'portalCheckLogins'} && $req->data->{'login'}
!ll&&!rl&&r
010
scalar $req->param('checkLogins') || 0
l!l
01
scalar $req->param('stayconnected') || 0
l!l
01
MC/DC0%0/1
$req->data->{'confirmFormAction'} || '#'
$req->data->{'confirmFormAction'}
MC/DC0%0/2
$self->conf->{'portalCheckLogins'} && $req->data->{'login'}
$self->conf->{'portalCheckLogins'} $req->data->{'login'}
MC/DC0%0/1
scalar $req->param('checkLogins') || 0
scalar $req->param('checkLogins')
MC/DC0%0/1
scalar $req->param('stayconnected') || 0
scalar $req->param('stayconnected')
Truth table50%1/2
A
A= $req->data->{'confirmFormAction'}
Aresult
11
00
Truth table33%1/3
A && B
A= $self->conf->{'portalCheckLogins'}B= $req->data->{'login'}
ABresult
0X0
100
111
Truth table50%1/2
A
A= scalar $req->param('checkLogins')
Aresult
11
00
Truth table50%1/2
A
A= scalar $req->param('stayconnected')
Aresult
11
00
178 ),
179  
180 );
181 }
182  
183 # 1.2b An authentication (or userDB) module needs to ask a question
184 # before processing to the request
185 elsif ( $req->{error} == PE_IDPCHOICE ) {
186 3 $self->logger->debug('Display: IDP choice detected');
187 3 $skinfile = 'idpchoice';
188 %templateParams = (
189 $self->getErrorTplParams($req),
190 AUTH_URL => $req->{data}->{_url},
191 HIDDEN_INPUTS => $self->buildHiddenForm($req),
192 ACTIVE_TIMER => $req->data->{activeTimer},
193 FORM_METHOD => $self->conf->{confirmFormMethod},
194 CHOICE_PARAM => $self->conf->{authChoiceParam},
195 CHOICE_VALUE => $req->data->{_authChoice},
196 CHECK_LOGINS => $self->conf->{portalCheckLogins}
197 && $req->data->{login},
198 ASK_LOGINS => scalar $req->param('checkLogins') || 0,
199 ASK_STAYCONNECTED => scalar $req->param('stayconnected') || 0,
200 CONFIRMKEY => $self->stamp(),
201 LIST => $req->data->{list} || [],
202 LOGIN_HINT => $req->data->{suggestedLogin},
203 (
204 $req->data->{customScript}
205 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
206 3 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 3 3
Condition44%4/9
$self->conf->{'portalCheckLogins'} && $req->data->{'login'}
!ll&&!rl&&r
003
scalar $req->param('checkLogins') || 0
l!l
03
scalar $req->param('stayconnected') || 0
l!l
03
$req->data->{'list'} || []
l!l
30
MC/DC0%0/2
$self->conf->{'portalCheckLogins'} && $req->data->{'login'}
$self->conf->{'portalCheckLogins'} $req->data->{'login'}
MC/DC0%0/1
scalar $req->param('checkLogins') || 0
scalar $req->param('checkLogins')
MC/DC0%0/1
scalar $req->param('stayconnected') || 0
scalar $req->param('stayconnected')
MC/DC0%0/1
$req->data->{'list'} || []
$req->data->{'list'}
Truth table33%1/3
A && B
A= $self->conf->{'portalCheckLogins'}B= $req->data->{'login'}
ABresult
0X0
100
111
Truth table50%1/2
A
A= scalar $req->param('checkLogins')
Aresult
11
00
Truth table50%1/2
A
A= scalar $req->param('stayconnected')
Aresult
11
00
Truth table50%1/2
A
A= $req->data->{'list'}
Aresult
11
00
207 ),
208 );
209 }
210  
211 # 1.3 There is a message to display
212 elsif ( my $info = $req->info ) {
213 my $method =
214 14 ▶ $req->data->{infoFormMethod} || $self->conf->{infoFormMethod};
Condition33%1/3
$req->data->{'infoFormMethod'} || $self->conf->{'infoFormMethod'}
l!l&&r!l&&!r
0140
MC/DC0%0/2
$req->data->{'infoFormMethod'} || $self->conf->{'infoFormMethod'}
$req->data->{'infoFormMethod'} $self->conf->{'infoFormMethod'}
Truth table33%1/3
A || B
A= $req->data->{'infoFormMethod'}B= $self->conf->{'infoFormMethod'}
ABresult
1X1
011
000
215 14 $self->logger->debug('Display: info detected');
216 14 $self->logger->debug('Hidden values :');
217 $self->logger->debug( " $_: " . $req->{portalHiddenFormValues}->{$_} )
218 14 ▶ for keys %{ $req->{portalHiddenFormValues} // {} };
Condition50%1/2
$req->{"portalHiddenFormValues"} // {}
l!l
014
MC/DC0%0/1
$req->{"portalHiddenFormValues"} // {}
$req->{"portalHiddenFormValues"}
Truth table50%1/2
A
A= $req->{"portalHiddenFormValues"}
Aresult
11
00
219 14 $skinfile = 'info';
220  
221 14 ▶ if ( !$req->urldc and $req->error == PE_LOGOUT_OK ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $req->urldc and $req->error == 47) 2 12 14
Condition100%3/3
not $req->urldc and $req->error == 47
!ll&&!rl&&r
932
MC/DC100%2/2
not $req->urldc and $req->error == 47
not $req->urldc $req->error == 47
Truth table100%3/3
not(A) and B
A= not $req->urldcB= $req->error == 47
ABresult
0X0
100
111
222 2 $req->urldc( $self->buildUrl( $req->portal, { logout => 1 } ) );
223 }
224  
225 %templateParams = (
226 $self->getErrorTplParams($req),
227 MSG => $info,
228 URL => $req->urldc || $req->portal,
229 HIDDEN_INPUTS => $self->buildOutgoingHiddenForm( $req, $method ),
230 ACTIVE_TIMER => $req->data->{activeTimer},
231 CHOICE_PARAM => $self->conf->{authChoiceParam},
232 CHOICE_VALUE => $req->data->{_authChoice},
233 FORM_METHOD => $method,
234 (
235 ( not $req->{urldc} ) ? ( SEND_PARAMS => 1 )
236 : ()
237 ),
238 (
239 $req->data->{customScript}
240 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
241 14 ▶ : ()
Branch: 2 branches
BranchTrueFalseTotal
!$req->{'urldc'} ? : 3 11 14
$req->data->{'customScript'} ? : 0 14 14
Condition66%2/3
$req->urldc || $req->portal
l!l&&r!l&&!r
1130
MC/DC0%0/2
$req->urldc || $req->portal
$req->urldc $req->portal
Truth table66%2/3
A || B
A= $req->urldcB= $req->portal
ABresult
1X1
011
000
242 ),
243 );
244 }
245  
246 # 1.4 OpenID menu page
247 ▶ elsif ($req->{error} == PE_OPENID_EMPTY
Condition33%1/3
$req->{"error"} == 62 or $req->{"error"} == 63
l!l&&r!l&&!r
00378
MC/DC0%0/2
$req->{"error"} == 62 or $req->{"error"} == 63
$req->{"error"} == 62 $req->{"error"} == 63
Truth table33%1/3
A or B
A= $req->{"error"} == 62B= $req->{"error"} == 63
ABresult
1X1
011
000
248 or $req->{error} == PE_OPENID_BADID )
249 {
250 0 $skinfile = 'openid';
251  
252 my $openid_path =
253 0 $self->conf->{issuerDBOpenIDPath} =~ s/^.*?(\w+).*?$/$1/r;
254 my $id = $req->{sessionInfo}
255 0 ▶ ->{ $self->conf->{openIdAttr} || $self->conf->{whatToTrace} };
Condition0%0/3
$self->conf->{'openIdAttr'} || $self->conf->{'whatToTrace'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->conf->{'openIdAttr'} || $self->conf->{'whatToTrace'}
$self->conf->{'openIdAttr'} $self->conf->{'whatToTrace'}
Truth table0%0/3
A || B
A= $self->conf->{'openIdAttr'}B= $self->conf->{'whatToTrace'}
ABresult
1X1
011
000
256 %templateParams = (
257 $self->getErrorTplParams($req),
258 PROVIDERURI => $self->buildUrl( $req->portal, $openid_path, "" ),
259 MSG => $req->info(),
260 (
261 $req->data->{customScript}
262 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
263 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
264 ),
265 );
266 0 ▶ $templateParams{ID} = $req->data->{_openidPortal} . $id if ($id);
Branch: 1 branch
BranchTrueFalseTotal
if $id 0 0 0
267 }
268  
269 # 2. Good authentication
270  
271 # 2.1 Redirection
272 elsif ( $req->{error} == PE_REDIRECT ) {
273 0 ▶ my $method = $req->data->{redirectFormMethod} || 'get';
Condition0%0/2
$req->data->{'redirectFormMethod'} || 'get'
l!l
00
MC/DC0%0/1
$req->data->{'redirectFormMethod'} || 'get'
$req->data->{'redirectFormMethod'}
Truth table0%0/2
A
A= $req->data->{'redirectFormMethod'}
Aresult
11
00
274 0 $skinfile = "redirect";
275 %templateParams = (
276 URL => $req->{urldc},
277 HIDDEN_INPUTS => $self->buildOutgoingHiddenForm( $req, $method ),
278 FORM_METHOD => $method,
279 (
280 $req->data->{customScript}
281 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
282 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
283 ),
284 );
285 }
286  
287 # 2.1 Wait for 2FA
288 elsif ( $req->{error} == PE_2FWAIT ) {
289 1 ▶ my $method = $req->data->{redirectFormMethod} || 'get';
Condition50%1/2
$req->data->{'redirectFormMethod'} || 'get'
l!l
10
MC/DC0%0/1
$req->data->{'redirectFormMethod'} || 'get'
$req->data->{'redirectFormMethod'}
Truth table50%1/2
A
A= $req->data->{'redirectFormMethod'}
Aresult
11
00
290 1 $skinfile = "2fwait";
291 %templateParams = (
292 URL => $req->{urldc},
293 HIDDEN_INPUTS => $self->buildOutgoingHiddenForm( $req, $method ),
294 FORM_METHOD => $method,
295 (
296 $req->data->{customScript}
297 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
298 1 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 1 1
299 ),
300 );
301 }
302  
303 # 2.2 Case : display menu (with error or not)
304 ▶ elsif ( $req->error == PE_OK || $req->error == PE_ISSUERTIMEOUT ) {
Condition66%2/3
$req->error == 0 or $req->error == 113
l!l&&r!l&&!r
120365
MC/DC50%1/2
$req->error == 0 or $req->error == 113
$req->error == 0 $req->error == 113
Truth table66%2/3
A or B
A= $req->error == 0B= $req->error == 113
ABresult
1X1
011
000
305 12 $skinfile = 'menu';
306  
307 #utf8::decode($auth_user);
308 %templateParams = (
309 AUTH_USER => $req->{sessionInfo}->{ $self->conf->{portalUserAttr} },
310 NEWWINDOW => $self->conf->{portalOpenLinkInNewWindow},
311 LOGOUT_URL => $self->buildUrl( $req->portal, { logout => 1 } ),
312 APPSLIST_ORDER => $req->{sessionInfo}->{'_appsListOrder'},
313 PING => $self->conf->{portalPingInterval},
314 DONT_STORE_PASSWORD => $self->conf->{browsersDontStorePassword},
315 HIDE_OLDPASSWORD => 0,
316 ENABLE_PASSWORD_DISPLAY =>
317 $self->conf->{portalEnablePasswordDisplay},
318 12 ▶ %{ $self->getPasswordPolicyTemplateVars },
Branch: 2 branches
BranchTrueFalseTotal
$self->requireOldPwd->($req, $req->userData) ? : 12 0 12
$req->data->{'customScript'} ? : 0 12 12
319 (
320 $self->requireOldPwd->( $req, $req->userData )
321 ? ( REQUIRE_OLDPASSWORD => 1 )
322 : ()
323 ),
324 $self->menu->params($req),
325 (
326 $req->data->{customScript}
327 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
328 12 : ()
329 ),
330 );
331 }
332  
333 # when upgrading session, the administrator can configure LLNG
334 # to ask only for 2FA
335 elsif ( $req->error == PE_UPGRADESESSION ) {
336 0 $skinfile = 'upgradesession';
337 %templateParams = (
338 FORMACTION => '/upgradesession',
339 MSG => 'askToUpgrade',
340 PORTALBUTTON => 1,
341 BUTTON => 'upgradeSession',
342 CONFIRMKEY => $self->stamp,
343 PORTAL => $req->portal,
344 URL => $req->data->{_url},
345 (
346 $req->data->{customScript}
347 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
348 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
349 ),
350 );
351 }
352  
353 # renew uses the same plugin as upgrade, but first factor is mandatory
354 elsif ( $req->error == PE_RENEWSESSION ) {
355 0 $skinfile = 'upgradesession';
356 %templateParams = (
357 FORMACTION => '/renewsession',
358 MSG => 'askToRenew',
359 CONFIRMKEY => $self->stamp,
360 PORTAL => $req->portal,
361 PORTALBUTTON => 1,
362 BUTTON => 'renewSession',
363 URL => $req->data->{_url},
364 (
365 $req->data->{customScript}
366 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
367 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
368 ),
369 );
370 }
371  
372 # Looks a lot like upgradesession, but no portal logo
373 elsif ( $req->error == PE_MUSTAUTHN ) {
374 0 $skinfile = 'upgradesession';
375 %templateParams = (
376 FORMACTION => '/renewsession',
377 MSG => 'PE87',
378 CONFIRMKEY => $self->stamp,
379 BUTTON => 'renewSession',
380 PORTAL => $req->portal,
381 URL => $req->data->{_url},
382 (
383 $req->data->{customScript}
384 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
385 0 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 0 0
386 ),
387 );
388 }
389  
390 # 2.3 Case : user authenticated but an error was returned (bad url,...)
391 ▶ elsif (
Condition75%9/12
$req->noLoginDisplay or not $req->data->{"noerror"} and $req->userData and %{$req->userData;} or $self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
l!l&&r!l&&!r
2819318
$req->noLoginDisplay or not $req->data->{"noerror"} and $req->userData and %{$req->userData;}
l!l&&r!l&&!r
1216337
not $req->data->{"noerror"} and $req->userData and %{$req->userData;}
!ll&&!rl&&r
033716
not $req->data->{"noerror"} and $req->userData
!ll&&!rl&&r
00353
MC/DC60%3/5
$req->noLoginDisplay or not $req->data->{"noerror"} and $req->userData and %{$req->userData;} or $self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
$req->noLoginDisplay not $req->data->{"noerror"} $req->userData %{$req->userData;} $self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
Truth table50%4/8
A or not(B) and C and D or E
A= $req->noLoginDisplayB= not $req->data->{"noerror"}C= $req->userDataD= %{$req->userData;}E= $self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
ABCDEresult
1XXXX1
0111X1
00XX11
010X11
011011
00XX00
010X00
011000
392 $req->noLoginDisplay
393 or ( not $req->data->{noerror}
394 and $req->userData
395 353 ▶ and %{ $req->userData } )
Condition71%15/21
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
!ll&&!rl&&r
318019
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39
!ll&&!rl&&r
318019
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22
!ll&&!rl&&r
318019
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25
!ll&&!rl&&r
318019
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5
!ll&&!rl&&r
318019
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9
!ll&&!rl&&r
311719
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0
!ll&&!rl&&r
311026
MC/DC0%0/8
$self->conf->{"authentication"} eq "Combination" and $req->{"error"} > 0 and $req->{"error"} != 9 and $req->{"error"} != 5 and $req->{"error"} != 25 and $req->{"error"} != 22 and $req->{"error"} != 39 and $req->{"error"} != 112
$self->conf->{"authentication"} eq "Combination" $req->{"error"} > 0 $req->{"error"} != 9 $req->{"error"} != 5 $req->{"error"} != 25 $req->{"error"} != 22 $req->{"error"} != 39 $req->{"error"} != 112
Truth table0%0/9
A and B and C and D and E and F and G and H
A= $self->conf->{"authentication"} eq "Combination"B= $req->{"error"} > 0C= $req->{"error"} != 9D= $req->{"error"} != 5E= $req->{"error"} != 25F= $req->{"error"} != 22G= $req->{"error"} != 39H= $req->{"error"} != 112
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
396  
397 # Avoid issue 1867
398 or ( $self->conf->{authentication} eq 'Combination'
399 and $req->{error} > PE_OK
400 and $req->{error} != PE_FIRSTACCESS
401 and $req->{error} != PE_BADCREDENTIALS
402 and $req->{error} != PE_PP_CHANGE_AFTER_RESET
403 and $req->{error} != PE_PP_PASSWORD_EXPIRED
404 and $req->{error} != PE_BADOLDPASSWORD
405 and $req->{error} != PE_PP_PASSWORD_EXPIRES_SOON )
406 )
407 {
408 47 $skinfile = 'error';
409 %templateParams = (
410 $self->getErrorTplParams($req),
411 (
412 $req->data->{customScript}
413 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
414 47 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 0 47 47
415 ),
416 );
417 }
418  
419 # 3 Authentication has been refused OR first access
420 else {
421 318 $skinfile = 'login';
422 318 ▶ my $login = $req->user || $req->data->{suggestedLogin};
Condition66%2/3
$req->user || $req->data->{'suggestedLogin'}
l!l&&r!l&&!r
140304
MC/DC50%1/2
$req->user || $req->data->{'suggestedLogin'}
$req->user $req->data->{'suggestedLogin'}
Truth table66%2/3
A || B
A= $req->userB= $req->data->{'suggestedLogin'}
ABresult
1X1
011
000
423 %templateParams = (
424 $self->getErrorTplParams($req),
425 AUTH_URL => $req->{data}->{_url},
426 LOGIN => $login,
427 ACTIVE_FORM => 1,
428 DONT_STORE_PASSWORD => $self->conf->{browsersDontStorePassword},
429 CHECK_LOGINS => $self->conf->{portalCheckLogins},
430 ASK_LOGINS => scalar $req->param('checkLogins') || 0,
431 ASK_STAYCONNECTED => scalar $req->param('stayconnected') || 0,
432 DISPLAY_RESETPASSWORD => $self->conf->{portalDisplayResetPassword},
433 DISPLAY_REGISTER => $self->conf->{portalDisplayRegister},
434 DISPLAY_UPDATECERTIF =>
435 $self->conf->{portalDisplayCertificateResetByMail},
436 MAILCERTIF_URL => $self->certificateResetUrl,
437 MAIL_URL => $self->passwordResetUrl,
438 REGISTER_URL => $self->registerUrl,
439 HIDDEN_INPUTS => $self->buildHiddenForm($req),
440 IMPERSONATION => $self->conf->{impersonationRule}
441 || $self->conf->{proxyAuthServiceImpersonation},
442 ENABLE_PASSWORD_DISPLAY =>
443 $self->conf->{portalEnablePasswordDisplay},
444 318 ▶ %{ $self->getPasswordPolicyTemplateVars },
Branch: 3 branches
BranchTrueFalseTotal
$self->conf->{'trustedBrowserRule'} || $self->stayConnected->($req, $req->sessionInfo) ? : 40 278 318
$self->rememberAuthChoice->($req, $req->sessionInfo) ? : 3 315 318
$req->data->{'customScript'} ? : 4 314 318
Condition77%7/9
$self->conf->{"trustedBrowserRule"} or $self->stayConnected->($req, $req->sessionInfo)
l!l&&r!l&&!r
2812278
$self->conf->{"rememberDefaultChecked"} // 0
l!l
3315
$self->conf->{"rememberCookieName"} // "llngrememberauthchoice"
l!l
3180
$self->conf->{"rememberTimer"} // 5
l!l
3180
MC/DC100%2/2
$self->conf->{"trustedBrowserRule"} or $self->stayConnected->($req, $req->sessionInfo)
$self->conf->{"trustedBrowserRule"} $self->stayConnected->($req, $req->sessionInfo)
MC/DC100%1/1
$self->conf->{"rememberDefaultChecked"} // 0
$self->conf->{"rememberDefaultChecked"}
MC/DC0%0/1
$self->conf->{"rememberCookieName"} // "llngrememberauthchoice"
$self->conf->{"rememberCookieName"}
MC/DC0%0/1
$self->conf->{"rememberTimer"} // 5
$self->conf->{"rememberTimer"}
Truth table100%3/3
A or B
A= $self->conf->{"trustedBrowserRule"}B= $self->stayConnected->($req, $req->sessionInfo)
ABresult
1X1
011
000
Truth table100%2/2
A
A= $self->conf->{"rememberDefaultChecked"}
Aresult
11
00
Truth table50%1/2
A
A= $self->conf->{"rememberCookieName"}
Aresult
11
00
Truth table50%1/2
A
A= $self->conf->{"rememberTimer"}
Aresult
11
00
445 ( (
446 $self->conf->{trustedBrowserRule}
447 or $self->stayConnected->( $req, $req->sessionInfo )
448 ) ? ( STAYCONNECTED => 1 )
449 : ()
450 ),
451 BROWSER_ALREADY_TRUSTED => $req->{data}->{browserAlreadyTrusted},
452 (
453 $self->rememberAuthChoice->( $req, $req->sessionInfo )
454 ? ( REMEMBERAUTHCHOICE => 1 )
455 : ()
456 ),
457 REMEMBERAUTHCHOICEDEFAULTCHECKED =>
458 $self->conf->{rememberDefaultChecked} // 0,
459 REMEMBERAUTHCHOICECOOKIENAME => $self->conf->{rememberCookieName}
460 // 'llngrememberauthchoice',
461 REMEMBERAUTHCHOICETIMER => $self->conf->{rememberTimer} // 5,
462 (
463 $req->data->{customScript}
464 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
465 318 ▶ : ()
Condition57%4/7
scalar $req->param('checkLogins') || 0
l!l
0318
scalar $req->param('stayconnected') || 0
l!l
0318
$self->conf->{'impersonationRule'} || $self->conf->{'proxyAuthServiceImpersonation'}
l!l&&r!l&&!r
10317
MC/DC0%0/1
scalar $req->param('checkLogins') || 0
scalar $req->param('checkLogins')
MC/DC0%0/1
scalar $req->param('stayconnected') || 0
scalar $req->param('stayconnected')
MC/DC50%1/2
$self->conf->{'impersonationRule'} || $self->conf->{'proxyAuthServiceImpersonation'}
$self->conf->{'impersonationRule'} $self->conf->{'proxyAuthServiceImpersonation'}
Truth table50%1/2
A
A= scalar $req->param('checkLogins')
Aresult
11
00
Truth table50%1/2
A
A= scalar $req->param('stayconnected')
Aresult
11
00
Truth table66%2/3
A || B
A= $self->conf->{'impersonationRule'}B= $self->conf->{'proxyAuthServiceImpersonation'}
ABresult
1X1
011
000
466 ),
467 );
468  
469 # External links
470 318 ▶ if ( $self->conf->{portalDisplayResetPassword} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{"portalDisplayResetPassword"}) 0 318 318
471 0 $templateParams{"MAIL_URL_EXTERNAL"} =
472 $self->_isExternalUrl( $req, $self->passwordResetUrl );
473 }
474 318 ▶ if ( $self->conf->{portalDisplayRegister} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{"portalDisplayRegister"}) 318 0 318
475 318 $templateParams{"REGISTER_URL_EXTERNAL"} =
476 $self->_isExternalUrl( $req, $self->registerUrl );
477 }
478 318 ▶ if ( $self->conf->{portalDisplayCertificateResetByMail} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{"portalDisplayCertificateResetByMail"}) 0 318 318
479 $templateParams{MAILCERTIF_URL_EXTERNAL} =
480 0 $self->_isExternalUrl( $req, $self->certificateResetUrl );
481 }
482  
483 # Display captcha if it's enabled
484 318 ▶ if ( $req->captchaHtml ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->captchaHtml) 3 315 318
485 3 %templateParams =
486 ( %templateParams, CAPTCHA_HTML => $req->captchaHtml, );
487 }
488 318 ▶ if ( $req->token ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->token) 7 311 318
489 7 %templateParams = ( %templateParams, TOKEN => $req->token, );
490 }
491  
492 # DEPRECATED: This is only used for compatibility with existing templates
493 318 ▶ if ( $req->captcha ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->captcha) 0 318 318
494 %templateParams = (
495 %templateParams,
496 CAPTCHA_SRC => $req->captcha,
497 0 ▶ CAPTCHA_SIZE => $self->{conf}->{captcha_size} || 6
Condition0%0/2
$self->{'conf'}{'captcha_size'} || 6
l!l
00
MC/DC0%0/1
$self->{'conf'}{'captcha_size'} || 6
$self->{'conf'}{'captcha_size'}
Truth table0%0/2
A
A= $self->{'conf'}{'captcha_size'}
Aresult
11
00
498 );
499 }
500  
501 # Show password form if password policy error
502 318 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($req->{'error'} == 25 or $req->{'error'} == 27 or $req->{'error'} == 28 or $req->{'error'} == 29 or $req->{'error'} == 30 or $req->{'error'} == 31 or $req->{'error'} == 34 or $req->{'error'} == 39 or $req->{'error'} == 67 or $req->{'error'} == 112 or $req->{'error'} == 22 and $self->conf->{'ldapAllowResetExpiredPassword'}) { } 0 318 318
elsif ($req->{'error'} == 47 or $req->{'error'} == 86 or $req->{'error'} == 37) { } 41 277 318
Condition33%11/33
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34 or $req->{"error"} == 39 or $req->{"error"} == 67 or $req->{"error"} == 112 or $req->{"error"} == 22 and $self->conf->{"ldapAllowResetExpiredPassword"}
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34 or $req->{"error"} == 39 or $req->{"error"} == 67 or $req->{"error"} == 112
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34 or $req->{"error"} == 39 or $req->{"error"} == 67
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34 or $req->{"error"} == 39
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28
l!l&&r!l&&!r
00318
$req->{"error"} == 25 or $req->{"error"} == 27
l!l&&r!l&&!r
00318
$req->{"error"} == 22 and $self->conf->{"ldapAllowResetExpiredPassword"}
!ll&&!rl&&r
31800
MC/DC0%0/12
$req->{"error"} == 25 or $req->{"error"} == 27 or $req->{"error"} == 28 or $req->{"error"} == 29 or $req->{"error"} == 30 or $req->{"error"} == 31 or $req->{"error"} == 34 or $req->{"error"} == 39 or $req->{"error"} == 67 or $req->{"error"} == 112 or $req->{"error"} == 22 and $self->conf->{"ldapAllowResetExpiredPassword"}
$req->{"error"} == 25 $req->{"error"} == 27 $req->{"error"} == 28 $req->{"error"} == 29 $req->{"error"} == 30 $req->{"error"} == 31 $req->{"error"} == 34 $req->{"error"} == 39 $req->{"error"} == 67 $req->{"error"} == 112 $req->{"error"} == 22 $self->conf->{"ldapAllowResetExpiredPassword"}
Truth table7%1/13
A or B or C or D or E or F or G or H or I or J or K and L
A= $req->{"error"} == 25B= $req->{"error"} == 27C= $req->{"error"} == 28D= $req->{"error"} == 29E= $req->{"error"} == 30F= $req->{"error"} == 31G= $req->{"error"} == 34H= $req->{"error"} == 39I= $req->{"error"} == 67J= $req->{"error"} == 112K= $req->{"error"} == 22L= $self->conf->{"ldapAllowResetExpiredPassword"}
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
0000000000111
00000000000X0
0000000000100
503  
504 $req->{error} == PE_PP_CHANGE_AFTER_RESET
505 or $req->{error} == PE_PP_MUST_SUPPLY_OLD_PASSWORD
506 or $req->{error} == PE_PP_INSUFFICIENT_PASSWORD_QUALITY
507 or $req->{error} == PE_PP_PASSWORD_TOO_SHORT
508 or $req->{error} == PE_PP_PASSWORD_TOO_YOUNG
509 or $req->{error} == PE_PP_PASSWORD_IN_HISTORY
510 or $req->{error} == PE_PASSWORD_MISMATCH
511 or $req->{error} == PE_BADOLDPASSWORD
512 or $req->{error} == PE_PASSWORDFORMEMPTY
513 or $req->{error} == PE_PP_PASSWORD_EXPIRES_SOON
514 or ( $req->{error} == PE_PP_PASSWORD_EXPIRED
515 and $self->conf->{ldapAllowResetExpiredPassword} )
516 )
517 {
518 %templateParams = (
519 %templateParams,
520 REQUIRE_OLDPASSWORD =>
521 1, # Old password is required to check user credentials
522 DISPLAY_FORM => 0,
523 DISPLAY_OPENID_FORM => 0,
524 DISPLAY_YUBIKEY_FORM => 0,
525 DISPLAY_PASSWORD => 1,
526 DISPLAY_RESETPASSWORD => 0,
527 AUTH_LOOP => [],
528 CHOICE_PARAM => $self->conf->{authChoiceParam},
529 CHOICE_VALUE => $req->data->{_authChoice},
530 OLDPASSWORD => $self->conf->{hideOldPassword}
531 ? $self->ott->createToken( {
532 oldpassword => $self->conf->{cipher}
533 ->encrypt( $req->data->{oldpassword}, 1 )
534 }
535 )
536 : $self->checkXSSAttack( 'oldpassword',
537 $req->data->{oldpassword} ) ? ''
538 : $req->data->{oldpassword},
539 HIDE_OLDPASSWORD => $self->conf->{hideOldPassword},
540 DONT_STORE_PASSWORD => $self->conf->{browsersDontStorePassword},
541 ENABLE_PASSWORD_DISPLAY =>
542 $self->conf->{portalEnablePasswordDisplay},
543 0 ▶ %{ $self->getPasswordPolicyTemplateVars },
Branch: 2 branches
BranchTrueFalseTotal
$self->conf->{'hideOldPassword'} ? : 0 0 0
$self->checkXSSAttack('oldpassword', $req->data->{'oldpassword'}) ? : 0 0 0
544 );
545 }
546  
547 # Disable all forms on:
548 # * Logout message
549 # * Account lock
550 # * Bad URL error
551 ▶ elsif ($req->{error} == PE_LOGOUT_OK
Condition66%4/6
$req->{"error"} == 47 or $req->{"error"} == 86 or $req->{"error"} == 37
l!l&&r!l&&!r
410277
$req->{"error"} == 47 or $req->{"error"} == 86
l!l&&r!l&&!r
410277
MC/DC33%1/3
$req->{"error"} == 47 or $req->{"error"} == 86 or $req->{"error"} == 37
$req->{"error"} == 47 $req->{"error"} == 86 $req->{"error"} == 37
Truth table50%2/4
A or B or C
A= $req->{"error"} == 47B= $req->{"error"} == 86C= $req->{"error"} == 37
ABCresult
1XX1
01X1
0011
0000
552 or $req->{error} == PE_WAIT
553 or $req->{error} == PE_BADURL )
554 {
555 41 %templateParams = (
556 %templateParams,
557 DISPLAY_RESETPASSWORD => 0,
558 DISPLAY_FORM => 0,
559 DISPLAY_OPENID_FORM => 0,
560 DISPLAY_YUBIKEY_FORM => 0,
561 AUTH_LOOP => [],
562 MSG => $req->info(),
563 LOCKTIME => $req->lockTime(),
564 );
565 }
566  
567 # Display authentication form
568 else {
569 my $plugin =
570 $self->loadedModules->{
571 277 "Lemonldap::NG::Portal::Plugins::FindUser"};
572 277 my ( $fields, $slogin, $mandatory ) = ( [], '', 0 );
573  
574 277 ▶ if ( $plugin
Branch: 1 branch
BranchTrueFalseTotal
if ($plugin and $self->conf->{"findUser"} and $self->conf->{"impersonationRule"} and $self->conf->{"findUserSearchingAttributes"}) 0 277 277
Condition33%3/9
$plugin and $self->conf->{"findUser"} and $self->conf->{"impersonationRule"} and $self->conf->{"findUserSearchingAttributes"}
!ll&&!rl&&r
27700
$plugin and $self->conf->{"findUser"} and $self->conf->{"impersonationRule"}
!ll&&!rl&&r
27700
$plugin and $self->conf->{"findUser"}
!ll&&!rl&&r
27700
MC/DC0%0/4
$plugin and $self->conf->{"findUser"} and $self->conf->{"impersonationRule"} and $self->conf->{"findUserSearchingAttributes"}
$plugin $self->conf->{"findUser"} $self->conf->{"impersonationRule"} $self->conf->{"findUserSearchingAttributes"}
Truth table20%1/5
A and B and C and D
A= $pluginB= $self->conf->{"findUser"}C= $self->conf->{"impersonationRule"}D= $self->conf->{"findUserSearchingAttributes"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
575 && $self->conf->{findUser}
576 && $self->conf->{impersonationRule}
577 && $self->conf->{findUserSearchingAttributes} )
578 {
579 0 $slogin = $req->data->{findUser};
580 0 ( $fields, $mandatory ) = $plugin->buildForm();
581 }
582  
583 # Authentication loop
584 277 ▶ if ( $self->conf->{authentication} eq 'Choice'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{'authentication'} eq 'Choice' and my $authLoop = $self->_buildAuthLoop($req)) { } 17 260 277
Condition66%2/3
$self->conf->{"authentication"} eq "Choice" and my $authLoop = $self->_buildAuthLoop($req)
!ll&&!rl&&r
260017
MC/DC50%1/2
$self->conf->{"authentication"} eq "Choice" and my $authLoop = $self->_buildAuthLoop($req)
$self->conf->{"authentication"} eq "Choice" my $authLoop = $self->_buildAuthLoop($req)
Truth table66%2/3
A and B
A= $self->conf->{"authentication"} eq "Choice"B= my $authLoop = $self->_buildAuthLoop($req)
ABresult
0X0
100
111
585 and my $authLoop = $self->_buildAuthLoop($req) )
586 {
587 %templateParams = (
588 %templateParams,
589 AUTH_LOOP => $authLoop,
590 CHOICE_PARAM => $self->conf->{authChoiceParam},
591 CHOICE_VALUE => $req->data->{_authChoice},
592 DISPLAY_FORM => 0,
593 DISPLAY_OPENID_FORM => 0,
594 DISPLAY_YUBIKEY_FORM => 0,
595 DISPLAY_FINDUSER => scalar @$fields,
596 MANDATORY => $mandatory,
597 FIELDS => $fields,
598 SPOOFID => $slogin,
599  
600 # Hidden inputs and custom scripts may have been modified
601 # by _buildAuthLoop so we need to update them
602 HIDDEN_INPUTS => $self->buildHiddenForm($req),
603 (
604 $req->data->{customScript}
605 ? ( CUSTOM_SCRIPT => $req->data->{customScript} )
606 17 ▶ : ()
Branch: 1 branch
BranchTrueFalseTotal
$req->data->{'customScript'} ? : 3 14 17
607 ),
608 );
609 }
610  
611 # Choose which form to display if not in a loop
612 else {
613 my $displayType =
614 260 ▶ eval { $self->_authentication->getDisplayType($req) }
Condition50%1/2
eval { do { $self->_authentication->getDisplayType($req) } } || 'logo'
l!l
2600
MC/DC0%0/1
eval { do { $self->_authentication->getDisplayType($req) } } || 'logo'
eval { do { $self->_authentication->getDisplayType($req) } }
Truth table50%1/2
A
A= eval { do { $self->_authentication->getDisplayType($req) } }
Aresult
11
00
615 || 'logo';
616  
617 260 $self->logger->debug("Display type $displayType");
618  
619 260 ▶ %templateParams = (
Branch: 9 branches
BranchTrueFalseTotal
$displayType =~ /\bstandardform\b/ ? : 145 115 260
$displayType =~ /\bopenidform\b/ ? : 0 260 260
$displayType =~ /\byubikeyform\b/ ? : 0 260 260
$displayType =~ /sslform/ ? : 1 259 260
$displayType =~ /webauthnform/ ? : 0 260 260
$displayType =~ /gpgform/ ? : 0 260 260
$displayType eq 'logo' ? : 114 146 260
$displayType eq 'logo' ? : 114 146 260
$displayType eq 'logo' ? : 114 146 260
620 %templateParams,
621 DISPLAY_FORM => $displayType =~ /\bstandardform\b/ ? 1
622 : 0,
623 DISPLAY_OPENID_FORM => $displayType =~ /\bopenidform\b/ ? 1
624 : 0,
625 DISPLAY_YUBIKEY_FORM => $displayType =~ /\byubikeyform\b/
626 ? 1
627 : 0,
628 DISPLAY_SSL_FORM => $displayType =~ /sslform/ ? 1 : 0,
629 DISPLAY_WEBAUTHN_FORM => $displayType =~ /webauthnform/ ? 1
630 : 0,
631 DISPLAY_GPG_FORM => $displayType =~ /gpgform/ ? 1 : 0,
632 DISPLAY_LOGO_FORM => $displayType eq "logo" ? 1 : 0,
633 DISPLAY_FINDUSER => scalar @$fields,
634 module => $displayType eq "logo"
635 ? $self->getModule( $req, 'auth' )
636 : "",
637 AUTH_LOOP => [],
638 PORTAL_URL => ( $displayType eq "logo" ? $req->portal : 0 ),
639 MSG => $req->info(),
640 MANDATORY => $mandatory,
641 FIELDS => $fields,
642 SPOOFID => $slogin
643 );
644 }
645 }
646 }
647  
648 396 ▶ if ( $req->data->{waitingMessage} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->data->{"waitingMessage"}) 1 395 396
649 1 $templateParams{WAITING_MESSAGE} = 1;
650 }
651  
652 396 $self->logger->debug("Skin returned: $skinfile");
653 396 return ( $skinfile, \%templateParams );
654 }
655  
656 ##@method public void printImage(string file, string type)
657 # Print image to STDOUT
658 # @param $file The path to the file to print
659 # @param $type The content-type to use (ie: image/png)
660 # @return void
661 0 ▶sub staticFile {
Subroutine staticFile: not called CC=2 SCAR=17.9
Pod undocumented
662 0 my ( $self, $req, $file, $type ) = @_;
663 0 require Plack::Util;
664 0 require Cwd;
665 0 require HTTP::Date;
666 open my $fh, '<:raw', $self->conf->{templateDir} . "/$file"
667 or return $self->sendError( $req,
668 0 ▶ $self->conf->{templateDir} . "/$file: $!", 403 );
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:raw", $self->conf->{"templateDir"} . "/$file" or return $self->sendError($req, $self->conf->{"templateDir"} . "/${file}: $!", 403) 0 0 0
669 0 my @stat = stat $file;
670 0 Plack::Util::set_io_path( $fh, Cwd::realpath($file) );
671 return [
672 0 200,
673 [
674 'Content-Type' => $type,
675 'Content-Length' => $stat[7],
676 'Last-Modified' => HTTP::Date::time2str( $stat[9] )
677 ],
678 $fh,
679 ];
680 }
681  
682 15 ▶sub buildOutgoingHiddenForm {
Subroutine buildOutgoingHiddenForm: called CC=2 SCAR=6.9
Pod undocumented
683 15 my ( $self, $req, $method ) = @_;
684 15 my @extra_keys;
685  
686 15 ▶ if ( lc $method eq 'get' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $method eq "get") 14 1 15
687 14 my $uri = URI->new( $req->{urldc} );
688 14 @extra_keys = $uri->query_form;
689 }
690  
691 15 return $self->buildHiddenForm( $req, @extra_keys );
692 }
693  
694 354 ▶sub buildHiddenForm {
Subroutine buildHiddenForm: called CC=7 SCAR=20.6
Pod undocumented
695 354 my ( $self, $req, @extra_keys ) = @_;
696 354 my @keys = keys %{ $req->{portalHiddenFormValues} };
697 354 my $val = '';
698  
699 354 foreach (@keys) {
700  
701 # Check XSS attacks
702 next
703 if (!$req->data->{safeHiddenFormValues}->{$_}
704 23 ▶ && $self->checkXSSAttack( $_, $req->{portalHiddenFormValues}->{$_} )
Branch: 1 branch
BranchTrueFalseTotal
if not $req->data->{"safeHiddenFormValues"}{$_} and $self->checkXSSAttack($_, $req->{"portalHiddenFormValues"}{$_}) 0 23 23
Condition33%1/3
not $req->data->{"safeHiddenFormValues"}{$_} and $self->checkXSSAttack($_, $req->{"portalHiddenFormValues"}{$_})
!ll&&!rl&&r
0230
MC/DC0%0/2
not $req->data->{"safeHiddenFormValues"}{$_} and $self->checkXSSAttack($_, $req->{"portalHiddenFormValues"}{$_})
not $req->data->{"safeHiddenFormValues"}{$_} $self->checkXSSAttack($_, $req->{"portalHiddenFormValues"}{$_})
Truth table33%1/3
not(A) and B
A= not $req->data->{"safeHiddenFormValues"}{$_}B= $self->checkXSSAttack($_, $req->{"portalHiddenFormValues"}{$_})
ABresult
0X0
100
111
705 );
706  
707 $val .= qq{<input type="hidden" name="$_" value="}
708 23 . $req->{portalHiddenFormValues}->{$_} . '" />';
709 }
710  
711 354 ▶ while ( my ( $key, $value ) = splice( @extra_keys, 0, 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@extra_keys, 0, 2)) 5 354 359
712  
713 # Check XSS attacks
714 next
715 5 ▶ if (!$req->data->{safeHiddenFormValues}->{$key}
Branch: 1 branch
BranchTrueFalseTotal
if not $req->data->{"safeHiddenFormValues"}{$key} and $self->checkXSSAttack($key, $value) 0 5 5
Condition33%1/3
not $req->data->{"safeHiddenFormValues"}{$key} and $self->checkXSSAttack($key, $value)
!ll&&!rl&&r
050
MC/DC0%0/2
not $req->data->{"safeHiddenFormValues"}{$key} and $self->checkXSSAttack($key, $value)
not $req->data->{"safeHiddenFormValues"}{$key} $self->checkXSSAttack($key, $value)
Truth table33%1/3
not(A) and B
A= not $req->data->{"safeHiddenFormValues"}{$key}B= $self->checkXSSAttack($key, $value)
ABresult
0X0
100
111
716 && $self->checkXSSAttack( $key, $value ) );
717  
718 5 $val .= qq{<input type="hidden" name="$key" value="$value" />};
719 }
720  
721 354 return $val;
722 }
723  
724 # Return skin name
725 # @return skin name
726 848 ▶sub getSkin {
Subroutine getSkin: called CC=9 SCAR=26.4
Pod undocumented
727 848 my ( $self, $req ) = @_;
728 848 my $skin = $self->conf->{portalSkin};
729  
730 # Fill sessionInfo to eval rule if empty (unauthenticated user)
731 848 ▶ $req->{sessionInfo}->{_url} ||= $req->{urldc};
Condition100%3/3
$req->{"sessionInfo"}{"_url"} ||= $req->{"urldc"}
l!l&&r!l&&!r
5531762
MC/DC100%2/2
$req->{"sessionInfo"}{"_url"} ||= $req->{"urldc"}
$req->{"sessionInfo"}{"_url"} $req->{"urldc"}
Truth table100%3/3
A ||= B
A= $req->{"sessionInfo"}{"_url"}B= $req->{"urldc"}
ABresult
1X1
011
000
732 848 ▶ $req->{sessionInfo}->{ipAddr} ||= $req->address;
Condition100%3/3
$req->{"sessionInfo"}{"ipAddr"} ||= $req->address
l!l&&r!l&&!r
5173292
MC/DC100%2/2
$req->{"sessionInfo"}{"ipAddr"} ||= $req->address
$req->{"sessionInfo"}{"ipAddr"} $req->address
Truth table100%3/3
A ||= B
A= $req->{"sessionInfo"}{"ipAddr"}B= $req->address
ABresult
1X1
011
000
733  
734 # Load specific skin from skinRules
735 848 foreach my $rule ( @{ $self->skinRules } ) {
736 0 ▶ if ( $rule->[1]->( $req, $req->sessionInfo ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule->[1]->($req, $req->sessionInfo)) 0 0 0
737 0 my $directory = $self->conf->{templateDir} . '/' . $rule->[0];
738 0 ▶ if ( -d $directory ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $directory) { } 0 0 0
739 0 $skin = $rule->[0];
740 0 $self->logger->debug("Skin $skin selected from skin rule");
741 0 last;
742 }
743 else {
744 0 $self->logger->warn( "Skin $rule->[0] was not selected "
745 . "because $directory does not exist" );
746 }
747 }
748 }
749  
750 # Check skin GET/POST parameter
751 848 my $skinParam = $req->param('skin');
752 848 ▶ if ( defined $skinParam ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $skinParam) 78 770 848
753 78 ▶ if ( $skinParam =~ /^[\w\-]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skinParam =~ /^[\w\-]+$/) { } 78 0 78
754 78 ▶ if ( -d $self->getSkinTplDir($skinParam) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $self->getSkinTplDir($skinParam)) { } 78 0 78
755 78 $skin = $skinParam;
756 78 $self->logger->debug(
757 "Skin $skin selected from GET/POST parameter");
758 }
759 else {
760 0 $self->logger->warn(
761 "User tries to access nonexistent skin dir $skinParam");
762 }
763 }
764 else {
765 0 $self->logger->warn("Invalid skin name $skinParam");
766 }
767 }
768  
769 848 return $skin;
770 }
771  
772 # Build an HTML array to display sessions
773 # @param $sessions Array ref of hash ref containing sessions data
774 # @param $title Title of the array
775 # @param $displayUser To display "User" column
776 # @param $displaError To display "Error" column
777 # @return HTML string
778 30 ▶sub mkSessionArray {
Subroutine mkSessionArray: called CC=4 SCAR=15.6
Pod undocumented
779 30 my ( $self, $req, $sessions, $title, $displayUser, $displayError ) = @_;
780  
781 30 ▶ return "" unless ( ref $sessions eq "ARRAY" and @$sessions );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sessions eq "ARRAY" and @$sessions 24 6 30
Condition66%2/3
ref $sessions eq "ARRAY" and @$sessions
!ll&&!rl&&r
2406
MC/DC50%1/2
ref $sessions eq "ARRAY" and @$sessions
ref $sessions eq "ARRAY" @$sessions
Truth table66%2/3
A and B
A= ref $sessions eq "ARRAY"B= @$sessions
ABresult
0X0
100
111
782  
783 # Merge user configuration with plugin self-configuration
784 6 my %rememberedData = %{ $self->pluginSessionDataToRemember };
785 6 @rememberedData{ keys %{ $self->conf->{sessionDataToRemember} } } =
786 6 values %{ $self->conf->{sessionDataToRemember} };
787  
788 # Delete fields with an empty/undef/__hidden__ column name
789 delete @rememberedData{
790 grep {
791 6 ( not $rememberedData{$_} )
792 0 ▶ or ( $rememberedData{$_} eq "__hidden__" )
Condition0%0/3
!$rememberedData{$_} || $rememberedData{$_} eq '__hidden__'
l!l&&r!l&&!r
000
MC/DC0%0/2
!$rememberedData{$_} || $rememberedData{$_} eq '__hidden__'
!$rememberedData{$_} $rememberedData{$_} eq '__hidden__'
Truth table0%0/3
not(A) || B
A= !$rememberedData{$_}B= $rememberedData{$_} eq '__hidden__'
ABresult
1X1
011
000
793 } keys %rememberedData
794 };
795  
796 6 my @fields = sort( keys %rememberedData );
797  
798 return $self->loadTemplate(
799 $req,
800 'sessionArray',
801 params => {
802 title => $title,
803 displayUser => $displayUser,
804 displayError => $displayError,
805 0 fields => [ map { { name => $rememberedData{$_} } } @fields ],
806 sessions => [
807 map {
808 6 my $session = $_;
809 {
810 user => $session->{user},
811 utime => $session->{_utime},
812 ip => $session->{ipAddr},
813 values => [
814 map {
815 # Modifying key to remove ordering prefix
816 0 my $modifiedKey = $_;
817 0 $modifiedKey =~ s/(\d+_)?//;
818 {
819 0 v => $session->{$modifiedKey},
820 k => $modifiedKey,
821 "k_$modifiedKey" => 1
822 }
823 } @fields
824 ],
825 error => $session->{error},
826 8 displayUser => $displayUser,
827 displayError => $displayError,
828 }
829 } @$sessions
830 ],
831 }
832 );
833 }
834  
835 0 ▶sub mkOidcConsent {
Subroutine mkOidcConsent: not called CC=9 SCAR=45.0
Pod undocumented
836 0 my ( $self, $req, $session ) = @_;
837  
838 0 ▶ if ( defined( $self->conf->{oidcRPMetaDataOptions} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->conf->{"oidcRPMetaDataOptions"} and ref $self->conf->{"oidcRPMetaDataOptions"}) 0 0 0
Condition0%0/3
defined $self->conf->{"oidcRPMetaDataOptions"} and ref $self->conf->{"oidcRPMetaDataOptions"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->conf->{"oidcRPMetaDataOptions"} and ref $self->conf->{"oidcRPMetaDataOptions"}
defined $self->conf->{"oidcRPMetaDataOptions"} ref $self->conf->{"oidcRPMetaDataOptions"}
Truth table0%0/3
A and B
A= defined $self->conf->{"oidcRPMetaDataOptions"}B= ref $self->conf->{"oidcRPMetaDataOptions"}
ABresult
0X0
100
111
839 and ref( $self->conf->{oidcRPMetaDataOptions} ) )
840 {
841  
842 # Set default RP displayname
843 0 foreach my $oidc ( keys %{ $self->conf->{oidcRPMetaDataOptions} } ) {
844 $self->conf->{oidcRPMetaDataOptions}->{$oidc}
845 0 ▶ ->{oidcRPMetaDataOptionsDisplayName} ||= $oidc;
Condition0%0/3
$self->conf->{"oidcRPMetaDataOptions"}{$oidc}{"oidcRPMetaDataOptionsDisplayName"} ||= $oidc
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->conf->{"oidcRPMetaDataOptions"}{$oidc}{"oidcRPMetaDataOptionsDisplayName"} ||= $oidc
$self->conf->{"oidcRPMetaDataOptions"}{$oidc}{"oidcRPMetaDataOptionsDisplayName"} $oidc
Truth table0%0/3
A ||= B
A= $self->conf->{"oidcRPMetaDataOptions"}{$oidc}{"oidcRPMetaDataOptionsDisplayName"}B= $oidc
ABresult
1X1
011
000
846 }
847 }
848  
849 # Loading existing oidcConsents
850 0 $self->logger->debug("Searching OIDC Consents...");
851 0 my $_oidcConsents;
852 0 ▶ if ( exists $session->{_oidcConsents} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $session->{'_oidcConsents'}) { } 0 0 0
853 0 $_oidcConsents = eval {
854 0 from_json( $session->{_oidcConsents}, { allow_nonref => 1 } );
855 };
856 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
857 0 $self->logger->error("Corrupted session (_oidcConsents): $@");
858 0 return PE_ERROR;
859 }
860 }
861 else {
862 0 $self->logger->debug("No OIDC Consent found");
863 }
864 0 my $consents = {};
865 0 foreach (@$_oidcConsents) {
866 0 ▶ if ( defined $_->{rp} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_->{"rp"}) 0 0 0
867 0 my $rp = $_->{rp};
868 0 $self->logger->debug("RP { $rp } Consent found");
869 0 $consents->{$rp}->{epoch} = $_->{epoch};
870 0 $consents->{$rp}->{scope} = $_->{scope};
871 $consents->{$rp}->{displayName} =
872 $self->conf->{oidcRPMetaDataOptions}->{$rp}
873 0 ->{oidcRPMetaDataOptionsDisplayName};
874 }
875 }
876  
877 # Display existing oidcConsents
878 return $self->loadTemplate(
879 $req,
880 'oidcConsents',
881 params => {
882 partners => [
883 map {
884 0 {
885 name => $_,
886 epoch => $consents->{$_}->{epoch},
887 scope => $consents->{$_}->{scope},
888 displayName => $consents->{$_}->{displayName}
889 }
890 0 } ( sort keys %$consents )
891 ],
892 consents => join( ",", keys %$consents ),
893 }
894 );
895 }
896  
897 322 ▶sub _isExternalUrl {
Subroutine _isExternalUrl: called CC=1 SCAR=0.0
898 322 my ( $self, $req, $url ) = @_;
899 322 return ( index( $url, $req->portal ) < 0 );
900 }
901  
902 330 ▶sub getPasswordPolicyTemplateVars {
Subroutine getPasswordPolicyTemplateVars: called CC=4 SCAR=16.9
Pod undocumented
903 330 my ( $self, $req ) = @_;
904 return {
905 PPOLICY_RULES => $self->getPpolicyRules,
906 PPOLICY_NOPOLICY => !$self->isPP(),
907 ENABLE_CHECKHIBP => $self->conf->{checkHIBP},
908 DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
909 PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
910 PPOLICY_MAXSIZE => $self->conf->{passwordPolicyMaxSize},
911 PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
912 PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
913 PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
914 (
915 $self->conf->{passwordPolicyMinSpeChar}
916 ? ( PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar} )
917 : ()
918 ),
919 (
920 330 ▶ $self->conf->{passwordPolicyMinSpeChar} && $self->speChars()
Branch: 2 branches
BranchTrueFalseTotal
$self->conf->{'passwordPolicyMinSpeChar'} ? : 0 330 330
$self->conf->{'passwordPolicyMinSpeChar'} && $self->speChars ? : 0 330 330
Condition33%1/3
$self->conf->{"passwordPolicyMinSpeChar"} and $self->speChars
!ll&&!rl&&r
33000
MC/DC0%0/2
$self->conf->{"passwordPolicyMinSpeChar"} and $self->speChars
$self->conf->{"passwordPolicyMinSpeChar"} $self->speChars
Truth table33%1/3
A and B
A= $self->conf->{"passwordPolicyMinSpeChar"}B= $self->speChars
ABresult
0X0
100
111
921 ? (
922 PPOLICY_ALLOWEDSPECHAR => $self->speChars(),
923 PPOLICY_ALLOWEDSPECHAR_JSON =>
924 to_json( $self->speChars(), { allow_nonref => 1 } ),
925 )
926 : ()
927 ),
928 };
929 }
930  
931 669 ▶sub getPpolicyRules {
Subroutine getPpolicyRules: called CC=6 SCAR=32.7
Pod undocumented
932 669 my ($self) = @_;
933 669 my $result = [];
934  
935 # Avoid useless computation if ppolicy is not displayed
936 669 ▶ return $result if !$self->conf->{portalDisplayPasswordPolicy};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->conf->{"portalDisplayPasswordPolicy"} 669 0 669
937  
938 0 ▶ while ( my ( $id, $policy ) = each %{ $self->_ppRules } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->_ppRules;}) 0 0 0
939 0 push @$result, { %$policy, id => $id };
940 }
941  
942 # Sort ppolicy items by "order" numerically and then by "id" lexically
943 0 ▶ $result = [ sort { $a->{order} <=> $b->{order} || $a->{id} cmp $b->{id} }
Condition0%0/3
$Lemonldap::NG::Portal::Main::a->{'order'} <=> $Lemonldap::NG::Portal::Main::b->{'order'} || $Lemonldap::NG::Portal::Main::a->{'id'} cmp $Lemonldap::NG::Portal::Main::b->{'id'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Lemonldap::NG::Portal::Main::a->{'order'} <=> $Lemonldap::NG::Portal::Main::b->{'order'} || $Lemonldap::NG::Portal::Main::a->{'id'} cmp $Lemonldap::NG::Portal::Main::b->{'id'}
$Lemonldap::NG::Portal::Main::a->{'order'} <=> $Lemonldap::NG::Portal::Main::b->{'order'} $Lemonldap::NG::Portal::Main::a->{'id'} cmp $Lemonldap::NG::Portal::Main::b->{'id'}
Truth table0%0/3
A || B
A= $Lemonldap::NG::Portal::Main::a->{'order'} <=> $Lemonldap::NG::Portal::Main::b->{'order'}B= $Lemonldap::NG::Portal::Main::a->{'id'} cmp $Lemonldap::NG::Portal::Main::b->{'id'}
ABresult
1X1
011
000
944 @$result ];
945  
946 # Format data attributes for HTML::Template loop
947 # data => { foo => "bar" } becomes
948 # data => [ { key => "foo", value => "bar" } ]
949 0 for my $result (@$result) {
950 0 ▶ if ( ref( $result->{data} ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result->{"data"} eq "HASH") 0 0 0
951 $result->{data} = [
952 0 map { { key => $_, value => $result->{data}->{$_} } }
953 0 keys %{ $result->{data} }
954 ];
955 }
956 }
957 0 return $result;
958 }
959  
960 454 1;
« blib/lib/Lemonldap/NG/Portal/Lib/Net/LDAP.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/CheckDevOps.pm »