blib/lib/Lemonldap/NG/Portal/Issuer/Get.pm

filter: Statementstmt 28.7% 19 / 66 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 55.5% 5 / 9 Podpod 50.0% 2 / 4 totaltotal 23.6% 26 / 110 CC 15 SCAR 35.7
CC
15
Cov
20%
computeGetParams
72.0
run
30.0
init
20.0
CRAP 35.3
« blib/lib/Lemonldap/NG/Portal/Lib/WebAuthn.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/OIDCTokenExchange.pm »
1 package Lemonldap::NG::Portal::Issuer::Get;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Lemonldap::NG::Common::FormEncode;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Lemonldap::NG::Portal::Main::Constants qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 PE_OK
9 PE_UNAUTHORIZEDURL
10 PE_GET_SERVICE_NOT_ALLOWED URIRE
11 1 );
12  
13 1 our $VERSION = '2.23.0';
14  
15 1 extends 'Lemonldap::NG::Portal::Main::Issuer';
16  
17 1 has rule => ( is => 'rw' );
18  
19 # INITIALIZATION
20  
21 0 ▶sub init {
Subroutine init: not called CC=4 SCAR=30.0
Pod undocumented
22 0 my ($self) = @_;
23  
24 # Parse activation rule
25 0 my $hd = $self->p->HANDLER;
26 0 $self->logger->debug( "GET rule -> " . $self->conf->{issuerDBGetRule} );
27 my $rule =
28 0 $hd->buildSub( $hd->substitute( $self->conf->{issuerDBGetRule} ) );
29 0 ▶ unless ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rule) 0 0 0
30 0 ▶ my $error = $hd->tsv->{jail}->error || '???';
Condition0%0/2
$hd->tsv->{'jail'}->error || '???'
l!l
00
MC/DC0%0/1
$hd->tsv->{'jail'}->error || '???'
$hd->tsv->{'jail'}->error
Truth table0%0/2
A
A= $hd->tsv->{'jail'}->error
Aresult
11
00
31 0 $self->error("Bad GET activation rule -> $error");
32 0 return 0;
33 }
34 0 $self->{rule} = $rule;
35 0 ▶ return 0 unless $self->SUPER::init();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::init 0 0 0
36 0 return 1;
37 }
38  
39 # RUNNING METHODS
40  
41 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
42 0 my ( $self, $req ) = @_;
43  
44 # Check activation rule
45 0 ▶ unless ( $self->rule->( $req, $req->sessionInfo ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->rule->($req, $req->sessionInfo)) 0 0 0
46 0 $self->userLogger->error('GET service not authorized');
47 0 return PE_GET_SERVICE_NOT_ALLOWED;
48 }
49  
50 # Session ID
51 0 ▶ my $session_id = $req->{sessionInfo}->{_session_id} || $req->id;
Condition0%0/3
$req->{'sessionInfo'}{'_session_id'} || $req->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$req->{'sessionInfo'}{'_session_id'} || $req->id
$req->{'sessionInfo'}{'_session_id'} $req->id
Truth table0%0/3
A || B
A= $req->{'sessionInfo'}{'_session_id'}B= $req->id
ABresult
1X1
011
000
52  
53 # Session creation timestamp
54 0 ▶ my $time = $req->{sessionInfo}->{_utime} || time();
Condition0%0/2
$req->{'sessionInfo'}{'_utime'} || time
l!l
00
MC/DC0%0/1
$req->{'sessionInfo'}{'_utime'} || time
$req->{'sessionInfo'}{'_utime'}
Truth table0%0/2
A
A= $req->{'sessionInfo'}{'_utime'}
Aresult
11
00
55  
56 0 ▶ if ( $req->path =~ m#^$self->{conf}->{issuerDBGetPath}/logout# ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->path =~ m[^$self->{'conf'}{'issuerDBGetPath'}/logout]) { } 0 0 0
57 0 $self->logger->debug("IssuerGet: request for logout");
58  
59 # TODO
60 # Display a link to the provided URL
61 0 return PE_OK;
62 }
63 else {
64 0 $self->logger->debug("IssuerGet: request for login");
65 0 $self->computeGetParams($req);
66 0 return PE_OK;
67 }
68 }
69  
70 # Nothing to do here for now
71 0 ▶sub logout {
Subroutine logout: not called CC=1 SCAR=6.9
Pod documented
72 0 return PE_OK;
73 }
74  
75 # INTERNAL METHODS
76  
77 0 ▶sub computeGetParams {
Subroutine computeGetParams: not called CC=8 SCAR=42.8
Pod undocumented
78 0 my ( $self, $req ) = @_;
79  
80 # Additional GET variables
81 0 my %getPrms;
82 0 ▶ if ( exists $self->conf->{issuerDBGetParameters} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->conf->{'issuerDBGetParameters'}) { } 0 0 0
83 0 ▶ unless ( $req->urldc =~ URIRE ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($req->urldc =~ 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 0 0
84 0 $self->logger->error("Malformed url $req->urldc");
85 0 return;
86 }
87 0 ▶ my $vhost = $3 . ( $4 ? ":$4" : '' );
Branch: 1 branch
BranchTrueFalseTotal
$4 ? : 0 0 0
88 0 my $prms = $self->conf->{issuerDBGetParameters}->{$vhost};
89 0 ▶ unless ($prms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prms) 0 0 0
90 0 $self->logger->warn("IssuerGet: $vhost has no configuration");
91 0 return '';
92 }
93 0 foreach my $param ( keys %$prms ) {
94 0 my $value = $req->{sessionInfo}->{ $prms->{$param} };
95 0 $value =~ s/[\r\n\t]//;
96 0 $getPrms{$param} = $value;
97 }
98 $self->userLogger->notice( 'User '
99 . $req->sessionInfo->{ $self->conf->{whatToTrace} }
100 0 . " is authorized to access $vhost" );
101 }
102 else {
103 0 $self->logger->warn("IssuerGet: no configuration");
104 0 return;
105 }
106 0 my $getVars = build_urlencoded(%getPrms);
107  
108 # If there are some GET variables to send
109 # Add them to URL string
110 0 ▶ if ( $getVars ne "" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($getVars ne "") 0 0 0
111 0 my $urldc = $req->urldc;
112  
113 0 ▶ $urldc .= ( $urldc =~ /\?\w/ )
Branch: 1 branch
BranchTrueFalseTotal
$urldc =~ /\?\w/ ? : 0 0 0
114 ?
115  
116 # there are already get variables
117 "&" . $getVars
118 :
119  
120 # there are no get variables
121 "?" . $getVars;
122 0 $req->urldc($urldc);
123 }
124 }
125  
126 1 1;
« blib/lib/Lemonldap/NG/Portal/Lib/WebAuthn.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/OIDCTokenExchange.pm »