blib/lib/Lemonldap/NG/Portal/Lib/Choice.pm

filter: Statementstmt 81.8% 149 / 182 Branchbran 64.6% 53 / 82 Conditioncond 47.0% 24 / 51 MC/DCmcdc 24.1% 7 / 29 Subroutinesub 93.7% 15 / 16 Podpod 0.0% 0 / 3 totaltotal 68.3% 248 / 363 CC 63 SCAR 33.7
CC
63
Cov
72%
_buildAuthLoop
60.9
_getChoiceFromReq
27.1
init
16.5
CRAP 29.1
« blib/lib/Lemonldap/NG/Portal/2F/Register/Generic.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/SingleSession.pm »
1 package Lemonldap::NG::Portal::Lib::Choice;
2  
3 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 29 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use Safe;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use Lemonldap::NG::Portal::Main::Constants qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 PE_OK
8 URIRE
9 29 );
10  
11 27 extends 'Lemonldap::NG::Portal::Lib::Wrapper';
12 27 with 'Lemonldap::NG::Portal::Lib::OverConf';
13  
14 27 our $VERSION = '2.23.1';
15  
16 122 ▶has modules => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
17 122 ▶has rules => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
18 27 has type => ( is => 'rw' );
19 122 ▶has catch => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
20 27 has sessionKey => ( is => 'ro', default => '_choice' );
21  
22 27 my $_choiceRules;
23 27 my $_disabledModules = {};
24  
25 # INITIALIZATION
26  
27 # init() must be called by module::init() with a number:
28 # - 0 for auth
29 # - 1 for userDB
30 # - 2 for passwordDB
31 122 ▶sub init {
Subroutine init: called CC=13 SCAR=28.0
Pod undocumented
32 122 my ( $self, $type ) = @_;
33 122 $self->type($type);
34  
35 122 ▶ unless ( $self->conf->{authChoiceModules}
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->conf->{"authChoiceModules"} and %{$self->conf->{"authChoiceModules"};}) 0 122 122
Condition33%1/3
$self->conf->{"authChoiceModules"} and %{$self->conf->{"authChoiceModules"};}
!ll&&!rl&&r
00122
MC/DC0%0/2
$self->conf->{"authChoiceModules"} and %{$self->conf->{"authChoiceModules"};}
$self->conf->{"authChoiceModules"} %{$self->conf->{"authChoiceModules"};}
Truth table33%1/3
A and B
A= $self->conf->{"authChoiceModules"}B= %{$self->conf->{"authChoiceModules"};}
ABresult
0X0
100
111
36 122 and %{ $self->conf->{authChoiceModules} } )
37 {
38 0 $self->error("'authChoiceModules' is empty");
39 0 return 0;
40 }
41  
42 122 foreach my $name ( keys %{ $self->conf->{authChoiceModules} } ) {
43 my @mods =
44 258 split( /;\s*/, $self->conf->{authChoiceModules}->{$name} );
45 258 my $module = '::'
46 . [ 'Auth', 'UserDB', 'Password' ]->[$type] . '::'
47 . $mods[$type];
48 258 my $over;
49 258 ▶ if ( $mods[5] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mods[5]) 40 218 258
50 40 eval { $over = JSON::from_json( $mods[5] ) };
51 40 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 40 40
52 0 $self->logger->error("Bad over value ($@), skipped");
53 }
54 }
55 258 ▶ if ( $module = $self->loadModule( $module, $over ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module = $self->loadModule($module, $over)) { } 258 0 258
56 258 $self->modules->{$name} = $module;
57 258 $self->logger->debug(
58 [qw(Authentication User Password)]->[$type]
59 . " module $name selected" );
60 }
61 else {
62 0 $_disabledModules->{$name}->{$type} = 1;
63 0 $self->logger->error( "Choice: unable to load $name ("
64 . [ 'Auth', 'UserDB', 'Password' ]->[$type]
65 . "), disabling it: "
66 . $self->error );
67 0 $self->error('');
68 }
69  
70 # Test if auth module wants to catch some path
71 258 ▶ unless ($type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 126 132 258
72 126 ▶ if ( $module->can('catch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module->can("catch")) 0 126 126
73 0 $self->catch->{$name} = $module->catch;
74 }
75 }
76  
77 # Display conditions
78 258 my $cond = $mods[4];
79 258 ▶ if ( defined $cond and $cond ne "" ) { # 0 is a valid rule!
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond and $cond ne '') { } 4 254 258
Condition100%3/3
defined $cond and $cond ne ""
!ll&&!rl&&r
214404
MC/DC100%2/2
defined $cond and $cond ne ""
defined $cond $cond ne ""
Truth table100%3/3
A and B
A= defined $condB= $cond ne ""
ABresult
0X0
100
111
80 4 my $rule =
81 $self->p->buildRule( $cond, "Choice condition for $name" );
82 4 ▶ return 0 unless $rule;
Branch: 1 branch
BranchTrueFalseTotal
unless $rule 0 4 4
83 4 $_choiceRules->{$name} = $rule;
84 }
85 else {
86 254 $self->logger->debug("No rule for $name");
87 254 ▶ $_choiceRules->{$name} = sub { 1 };
Subroutine __ANON__: called CC=1 SCAR=0.0
88 }
89 }
90 122 ▶ unless ( keys %{ $self->modules } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$self->modules;}) 0 122 122
91 0 $self->error('Choice: no available module found, aborting');
92 0 return 0;
93 }
94 122 return 1;
95 }
96  
97 # RUNNING METHODS
98  
99 96 ▶sub checkChoice {
Subroutine checkChoice: called CC=5 SCAR=16.4
Pod undocumented
100 96 my ( $self, $req ) = @_;
101 96 my ( $name, $how ) = $self->_getChoiceFromReq($req);
102  
103 96 ▶ return 0 unless ($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $name 11 85 96
104 85 $self->logger->debug("Choice $name selected from $how");
105  
106 85 ▶ unless ( defined $self->modules->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->modules->{$name}) 0 85 85
107 0 $self->logger->error("Unknown choice '$name'");
108 0 return 0;
109 }
110  
111 85 ▶ unless ( $req->data->{findUserChoice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req->data->{"findUserChoice"}) 85 0 85
112  
113 # Store choice if module loops
114 85 $req->pdata->{_choice} = $name;
115 85 $req->data->{_authChoice} = $name;
116 85 $req->sessionInfo->{_choice} = $name;
117 85 $self->p->_authentication->authnLevel("${name}AuthnLevel");
118 }
119  
120 85 ▶ return $name if ( $req->data->{ "enabledMods" . $self->type } );
Branch: 1 branch
BranchTrueFalseTotal
if $req->data->{'enabledMods' . $self->type} 23 62 85
121 $req->data->{ "enabledMods" . $self->type } =
122 62 [ $self->modules->{$name} ];
123 62 return $name;
124 }
125  
126 96 ▶sub _getChoiceFromReq {
Subroutine _getChoiceFromReq: called CC=20 SCAR=33.0
127 96 my ( $self, $req ) = @_;
128  
129 # Check Choice from pdata, unless the request carries an explicit choice.
130 96 ▶ if ( defined $req->pdata->{_choice}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $req->pdata->{'_choice'} and not $req->parameters->get($self->conf->{'authChoiceParam'})) { } 3 93 96
elsif (defined $req->data->{'_authChoice'} or defined $req->data->{'_choice'}) { } 41 52 93
Condition100%3/3
defined $req->pdata->{"_choice"} and not $req->parameters->get($self->conf->{"authChoiceParam"})
!ll&&!rl&&r
52413
MC/DC100%2/2
defined $req->pdata->{"_choice"} and not $req->parameters->get($self->conf->{"authChoiceParam"})
defined $req->pdata->{"_choice"} not $req->parameters->get($self->conf->{"authChoiceParam"})
Truth table100%3/3
A and not(B)
A= defined $req->pdata->{"_choice"}B= not $req->parameters->get($self->conf->{"authChoiceParam"})
ABresult
0X0
100
111
131 and !$req->parameters->get( $self->conf->{authChoiceParam} ) )
132 {
133 3 return ( $req->pdata->{_choice}, "pdata" );
134 }
135 ▶ elsif (( defined $req->data->{_authChoice} )
Condition66%2/3
defined $req->data->{"_authChoice"} or defined $req->data->{"_choice"}
l!l&&r!l&&!r
41052
MC/DC50%1/2
defined $req->data->{"_authChoice"} or defined $req->data->{"_choice"}
defined $req->data->{"_authChoice"} defined $req->data->{"_choice"}
Truth table66%2/3
A or B
A= defined $req->data->{"_authChoice"}B= defined $req->data->{"_choice"}
ABresult
1X1
011
000
136 or ( defined $req->data->{_choice} ) )
137 {
138 41 ▶ my $name = $req->data->{_authChoice} || $req->data->{_choice};
Condition33%1/3
$req->data->{'_authChoice'} || $req->data->{'_choice'}
l!l&&r!l&&!r
4100
MC/DC0%0/2
$req->data->{'_authChoice'} || $req->data->{'_choice'}
$req->data->{'_authChoice'} $req->data->{'_choice'}
Truth table33%1/3
A || B
A= $req->data->{'_authChoice'}B= $req->data->{'_choice'}
ABresult
1X1
011
000
139 41 return ( $name, "req->data" );
140 }
141  
142 # Check with catch method
143 52 foreach ( keys %{ $self->catch } ) {
144 0 ▶ if ( $req->path_info =~ $self->catch->{$_} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->path_info =~ /$self->catch->{$_}/) 0 0 0
145 0 return ( $_, "caught path " . $req->path_info );
146 }
147 }
148  
149 # Set by OAuth Resource Owner grant // RESTServer pwdCheck
150 52 ▶ if ( $req->data->{_pwdCheck} and $self->{conf}->{authChoiceAuthBasic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->data->{"_pwdCheck"} and $self->{"conf"}{"authChoiceAuthBasic"}) 0 52 52
Condition33%1/3
$req->data->{"_pwdCheck"} and $self->{"conf"}{"authChoiceAuthBasic"}
!ll&&!rl&&r
5200
MC/DC0%0/2
$req->data->{"_pwdCheck"} and $self->{"conf"}{"authChoiceAuthBasic"}
$req->data->{"_pwdCheck"} $self->{"conf"}{"authChoiceAuthBasic"}
Truth table33%1/3
A and B
A= $req->data->{"_pwdCheck"}B= $self->{"conf"}{"authChoiceAuthBasic"}
ABresult
0X0
100
111
151 0 return ( $self->{conf}->{authChoiceAuthBasic}, "basic auth context" );
152 }
153  
154 52 ▶ if ( $req->data->{findUserChoice} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->data->{"findUserChoice"}) 0 52 52
155 0 return ( $req->data->{findUserChoice}, "findUser" );
156 }
157  
158 52 ▶ if ( $req->parameters->get( $self->conf->{authChoiceParam} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->parameters->get($self->conf->{"authChoiceParam"})) 22 30 52
159 22 return ( $req->parameters->get( $self->conf->{authChoiceParam} ),
160 "param" );
161 }
162  
163 # Use the choice from current session unless we are doing an upgrade
164 # in which case the user should be offered to choose again
165 30 ▶ unless ( $req->data->{discardChoiceForCurrentSession} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req->data->{"discardChoiceForCurrentSession"}) 30 0 30
166 30 ▶ if ( $req->userData->{_choice} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->userData->{"_choice"}) 8 22 30
167 8 return ( $req->userData->{_choice}, "userData" );
168 }
169 22 ▶ if ( $req->sessionInfo->{_choice} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->sessionInfo->{"_choice"}) 0 22 22
170 0 return ( $req->sessionInfo->{_choice}, "sessionInfo" );
171 }
172 }
173  
174 22 ▶ if ( $self->conf->{authChoiceSelectOnly} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conf->{"authChoiceSelectOnly"}) 9 13 22
175 9 my @allowed_choices = grep { $self->_evaluateRule( $req, $_ ) }
176 9 keys %{ $self->conf->{authChoiceModules} };
177 9 ▶ if ( @allowed_choices == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@allowed_choices == 1) 9 0 9
178 9 return ( $allowed_choices[0], "only available" );
179 }
180 }
181  
182 # Try hook
183 13 my $context = {};
184 13 my $h = $self->p->processHook( $req, 'getAuthChoice', $context );
185 13 ▶ return 0 if ( $h != PE_OK );
Branch: 1 branch
BranchTrueFalseTotal
if $h != 0 0 13 13
186 13 ▶ if ( $h == PE_OK and $context->{choice} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h == 0 and $context->{"choice"}) 2 11 13
Condition66%2/3
$h == 0 and $context->{"choice"}
!ll&&!rl&&r
0112
MC/DC50%1/2
$h == 0 and $context->{"choice"}
$h == 0 $context->{"choice"}
Truth table66%2/3
A and B
A= $h == 0B= $context->{"choice"}
ABresult
0X0
100
111
187 2 return ( $context->{choice}, "hook" );
188 }
189  
190 11 return 0;
191 }
192  
193 22 ▶sub name {
Subroutine name: called CC=3 SCAR=11.1
Pod undocumented
194 22 my ( $self, $req, $type ) = @_;
195 22 ▶ unless ($req) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req) 0 22 22
196 0 return 'Choice';
197 }
198  
199 22 my $module = $req->data->{ "enabledMods" . $self->type }->[0];
200 22 ▶ if ( my $sub = eval { $module->can('name') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = eval { do { $module->can('name') } }) { } 10 12 22
201 10 return $sub->( $module, $req, $type );
202 }
203 else {
204 12 my $n = ref($module);
205 12 $n =~ s/^Lemonldap::NG::Portal::(?:(?:UserDB|Auth)::)?//;
206 12 return $n;
207 }
208 }
209  
210 package Lemonldap::NG::Portal::Main;
211  
212 # Build authentication loop displayed in template
213 # Return authLoop array reference
214 17 ▶sub _buildAuthLoop {
Subroutine _buildAuthLoop: called CC=24 SCAR=41.1
215 17 my ( $self, $req ) = @_;
216 17 my @authLoop;
217  
218 # Test authentication choices
219 17 ▶ unless ( ref $self->conf->{authChoiceModules} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->conf->{"authChoiceModules"} eq "HASH") 0 17 17
220 0 $self->logger->warn("No authentication choices defined");
221 0 return [];
222 }
223  
224 17 foreach ( sort keys %{ $self->conf->{authChoiceModules} } ) {
225  
226 28 my $name = $_;
227  
228 # Name can have a digit as first character
229 # for sorting purpose
230 # Remove it in displayed name
231 28 $name =~ s/^(\d*)?(\s*)?//;
232  
233 # Replace also _ by space for a nice display
234 28 $name =~ s/\_/ /g;
235  
236 # Find modules associated to authChoice
237 my ( $auth, $userDB, $passwordDB, $url, $condition ) =
238 28 split( /;\s*/, $self->conf->{authChoiceModules}->{$_} );
239  
240 28 ▶ unless ( $self->_evaluateRule( $req, $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_evaluateRule($req, $_)) { } 28 0 28
241 0 $self->logger->debug(
242 "Condition returns false, authentication choice $_"
243 . " will not be displayed" );
244 }
245 else {
246 28 ▶ if ( $auth
Branch: 1 branch
BranchTrueFalseTotal
if ($auth and not $_disabledModules->{$_}{'0'} and $userDB and not $_disabledModules->{$_}{'1'} and $passwordDB and not $_disabledModules->{$_}{'2'}) { } 28 0 28
Condition33%5/15
$auth and not $_disabledModules->{$_}{0} and $userDB and not $_disabledModules->{$_}{1} and $passwordDB and not $_disabledModules->{$_}{2}
!ll&&!rl&&r
0028
$auth and not $_disabledModules->{$_}{0} and $userDB and not $_disabledModules->{$_}{1} and $passwordDB
!ll&&!rl&&r
0028
$auth and not $_disabledModules->{$_}{0} and $userDB and not $_disabledModules->{$_}{1}
!ll&&!rl&&r
0028
$auth and not $_disabledModules->{$_}{0} and $userDB
!ll&&!rl&&r
0028
$auth and not $_disabledModules->{$_}{0}
!ll&&!rl&&r
0028
MC/DC0%0/6
$auth and not $_disabledModules->{$_}{0} and $userDB and not $_disabledModules->{$_}{1} and $passwordDB and not $_disabledModules->{$_}{2}
$auth not $_disabledModules->{$_}{0} $userDB not $_disabledModules->{$_}{1} $passwordDB not $_disabledModules->{$_}{2}
Truth table14%1/7
A and not(B) and C and not(D) and E and not(F)
A= $authB= not $_disabledModules->{$_}{0}C= $userDBD= not $_disabledModules->{$_}{1}E= $passwordDBF= not $_disabledModules->{$_}{2}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
247 and not $_disabledModules->{$_}->{0}
248 and $userDB
249 and not $_disabledModules->{$_}->{1}
250 and $passwordDB
251 and not $_disabledModules->{$_}->{2} )
252 {
253 28 $self->logger->debug("Displaying authentication choice $_");
254  
255 # Default URL
256 28 ▶ $req->data->{cspFormAction} ||= {};
Condition100%2/2
$req->data->{"cspFormAction"} ||= {}
l!l
1117
MC/DC100%1/1
$req->data->{"cspFormAction"} ||= {}
$req->data->{"cspFormAction"}
Truth table100%2/2
A
A= $req->data->{"cspFormAction"}
Aresult
11
00
257 28 ▶ if ( defined $url and $url =~ URIRE ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $url and $url =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]) { } 0 28 28
Condition66%2/3
defined $url and $url =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
!ll&&!rl&&r
1990
MC/DC0%0/2
defined $url and $url =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
defined $url $url =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
Truth table66%2/3
A and B
A= defined $urlB= $url =~ m[(((?^:https?))://((?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::((?:[0-9]*)))?(/(((?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():\@&=+\$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?]((?:(?:[;/?:\@&=+\$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)]
ABresult
0X0
100
111
258 0 my $csp_uri = $self->cspGetHost($url);
259 0 $req->data->{cspFormAction}->{$csp_uri} = 1;
260 }
261 else {
262 28 $url .= '#';
263 }
264 28 $self->logger->debug("Use URL $url");
265  
266 28 eval {
267 28 my $mod = $self->_authentication->modules->{$_};
268 28 ▶ $mod->initDisplay($req) if $mod->can('initDisplay');
Branch: 1 branch
BranchTrueFalseTotal
if $mod->can("initDisplay") 28 0 28
269 };
270 28 ▶ $self->logger->info(
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 28 28
271 "Unable to initialize choice $_ display: $@")
272 if $@;
273  
274 28 my $name_without_space = $name =~ s/^\s*//r;
275  
276 # Options to store in the loop
277 28 my $optionsLoop = {
278 name => $name,
279 key => $_,
280 module => $auth,
281 url => $url,
282 "name_$name_without_space" => 1,
283 "module_$auth" => 1,
284 "key_$_" => 1,
285 };
286  
287 # Get displayType for this module
288 27 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
289 28 ▶ my $displayType = eval {
Condition50%1/2
eval { do { $self->_authentication->modules->{$_}->getDisplayType($req) } } || 'logo'
l!l
280
MC/DC0%0/1
eval { do { $self->_authentication->modules->{$_}->getDisplayType($req) } } || 'logo'
eval { do { $self->_authentication->modules->{$_}->getDisplayType($req) } }
Truth table50%1/2
A
A= eval { do { $self->_authentication->modules->{$_}->getDisplayType($req) } }
Aresult
11
00
290 28 $self->_authentication->modules->{$_}->getDisplayType($req);
291 } || 'logo';
292  
293 28 $self->logger->debug(
294 "Display type $displayType for module $auth");
295 28 $optionsLoop->{$displayType} = 1;
296 28 my $logo = $_;
297  
298 28 my $foundLogo = 0;
299  
300 # If displayType is logo, check if key.png is available
301 28 ▶ if ( -e $self->conf->{templateDir}
Branch: 1 branch
BranchTrueFalseTotal
if (-e $self->conf->{'templateDir'} . '/../htdocs/static/common/modules/' . $logo . '.png') { } 0 28 28
302 . "/../htdocs/static/common/modules/"
303 . $logo
304 . ".png" )
305 {
306 0 $optionsLoop->{logoFile} = $logo . ".png";
307 0 $foundLogo = 1;
308 }
309 else {
310 28 $optionsLoop->{logoFile} = $auth . ".png";
311 }
312  
313 # Compatibility, with Custom, try the module name if
314 # key was not found
315 28 ▶ if ( $auth eq 'Custom' and not $foundLogo ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth eq "Custom" and not $foundLogo) 0 28 28
Condition33%1/3
$auth eq "Custom" and not $foundLogo
!ll&&!rl&&r
2800
MC/DC0%0/2
$auth eq "Custom" and not $foundLogo
$auth eq "Custom" not $foundLogo
Truth table33%1/3
A and not(B)
A= $auth eq "Custom"B= not $foundLogo
ABresult
0X0
100
111
316 $logo =
317 0 ▶ ( ( $self->{conf}->{customAuth} || "" ) =~ /::(\w+)$/ )
Condition0%0/2
$self->{'conf'}{'customAuth'} || ''
l!l
00
MC/DC0%0/1
$self->{'conf'}{'customAuth'} || ''
$self->{'conf'}{'customAuth'}
Truth table0%0/2
A
A= $self->{'conf'}{'customAuth'}
Aresult
11
00
318 [0];
319 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($logo and -e $self->conf->{"templateDir"} . '/../htdocs/static/common/modules/' . $logo . '.png') 0 0 0
Condition0%0/3
$logo and -e $self->conf->{"templateDir"} . '/../htdocs/static/common/modules/' . $logo . '.png'
!ll&&!rl&&r
000
MC/DC0%0/2
$logo and -e $self->conf->{"templateDir"} . '/../htdocs/static/common/modules/' . $logo . '.png'
$logo -e $self->conf->{"templateDir"} . '/../htdocs/static/common/modules/' . $logo . '.png'
Truth table0%0/3
A and B
A= $logoB= -e $self->conf->{"templateDir"} . '/../htdocs/static/common/modules/' . $logo . '.png'
ABresult
0X0
100
111
320 $logo
321 and ( -e $self->conf->{templateDir}
322 . "/../htdocs/static/common/modules/"
323 . $logo
324 . ".png" )
325 )
326 {
327 0 $optionsLoop->{logoFile} = $logo . ".png";
328 }
329 }
330  
331 # If a choice has already been selected,
332 # activate the corresponding form
333 28 ▶ if ( $req->data->{_authChoice} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->data->{'_authChoice'}) { } 14 14 28
334 $optionsLoop->{ACTIVE_FORM} =
335 14 ( $req->data->{_authChoice} eq $_ );
336  
337 }
338  
339 # if not, activate the first form in the list
340 else {
341 14 ▶ $optionsLoop->{ACTIVE_FORM} = @authLoop ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@authLoop ? : 6 8 14
342 }
343  
344 # Register item in loop
345 28 push @authLoop, $optionsLoop;
346  
347 28 $self->logger->debug(
348 "Authentication choice $name_without_space will be displayed"
349 );
350 }
351 else {
352 0 $self->logger->debug(
353 "Authentication choice $_ is invalid and will not be displayed"
354 );
355 0 $req->error("Authentication choice $_ is invalid");
356 0 next;
357 }
358 }
359  
360 }
361  
362 17 return \@authLoop;
363  
364 }
365  
366 37 ▶sub _evaluateRule {
Subroutine _evaluateRule: called CC=3 SCAR=13.0
367 37 my ( $self, $req, $choice ) = @_;
368  
369 37 my $extraData = {};
370 $extraData->{targetAuthnLevel} = $req->pdata->{targetAuthnLevel}
371 37 ▶ if defined $req->pdata->{targetAuthnLevel};
Branch: 1 branch
BranchTrueFalseTotal
if defined $req->pdata->{"targetAuthnLevel"} 0 37 37
372 37 ▶ unless ( $_choiceRules->{$choice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_choiceRules->{$choice}) 0 37 37
373 0 $self->logger->error("$choice has no rule");
374 0 ▶ $_choiceRules->{$choice} = sub { 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
375 }
376 37 return $_choiceRules->{$_}->( $req, $extraData );
377 }
378  
379 27 1;
380  
« blib/lib/Lemonldap/NG/Portal/2F/Register/Generic.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/SingleSession.pm »