blib/lib/Lemonldap/NG/Portal/Plugins/OIDCInternalTokenExchange.pm

filter: Statementstmt 22.5% 9 / 40 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 2 / 4 Podpod 100% 2 / 2 totaltotal 16.8% 13 / 77 CC 12 SCAR 38.8
CC
12
Cov
14%
validateAudience
72.0
getUid
30.0
BEGIN
1.0
CRAP 48.5
« blib/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/2fDevices.pm »
1 package Lemonldap::NG::Portal::Plugins::OIDCInternalTokenExchange;
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  
6 1 extends 'Lemonldap::NG::Portal::Lib::OIDCTokenExchange';
7  
8 1 our $VERSION = '2.20.0';
9  
10 sub validateAudience {
11 0 ▶ my ( $self, $req, $rp, $target, $requestedTokenType ) = @_;
Subroutine validateAudience: not called CC=8 SCAR=42.8
Pod documented
12  
13 0 ▶ if ( $requestedTokenType and $requestedTokenType ne 'access_token' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requestedTokenType and $requestedTokenType ne "access_token") 0 0 0
Condition0%0/3
$requestedTokenType and $requestedTokenType ne "access_token"
!ll&&!rl&&r
000
MC/DC0%0/2
$requestedTokenType and $requestedTokenType ne "access_token"
$requestedTokenType $requestedTokenType ne "access_token"
Truth table0%0/3
A and B
A= $requestedTokenTypeB= $requestedTokenType ne "access_token"
ABresult
0X0
100
111
14 0 $self->logger->debug("Requested token isn't declared as access_token");
15 0 return 0;
16 }
17  
18 0 ▶ unless ( $target->{audience} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target->{"audience"}) 0 0 0
19 0 $target->{rp} = $rp;
20 0 return 1;
21 }
22  
23 0 ▶ unless ( $target->{rp} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target->{"rp"}) 0 0 0
24 0 $self->logger->debug(
25 "Token exchange request for an unexistent RP $target->{audience}");
26 0 return 0;
27 }
28  
29 0 ▶ return 1 if $target->{rp} eq $rp;
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"rp"} eq $rp 0 0 0
30  
31 my $list = $self->oidc->rpOptions->{ $target->{rp} }
32 0 ->{oidcRPMetaDataOptionsTokenXAuthorizedRP};
33 0 ▶ unless ( $list and grep { $_ eq $rp } split /[,;\s]+/, $list ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)) 0 0 0
Condition0%0/3
$list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
!ll&&!rl&&r
000
MC/DC0%0/2
$list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
$list grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
Truth table0%0/3
A and B
A= $listB= grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
ABresult
0X0
100
111
34 0 $self->logger->debug(
35 "Token exchange for an unauthorized RP ($rp => $target->{rp})");
36 0 return 0;
37 }
38 0 return 1;
39 }
40  
41 sub getUid {
42 0 ▶ my ( $self, $req, $rp, $subjectToken, $subjectTokenType ) = @_;
Subroutine getUid: not called CC=5 SCAR=34.0
Pod documented
43  
44 0 ▶ if ( $subjectTokenType and $subjectTokenType ne 'access_token' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subjectTokenType and $subjectTokenType ne "access_token") 0 0 0
Condition0%0/3
$subjectTokenType and $subjectTokenType ne "access_token"
!ll&&!rl&&r
000
MC/DC0%0/2
$subjectTokenType and $subjectTokenType ne "access_token"
$subjectTokenType $subjectTokenType ne "access_token"
Truth table0%0/3
A and B
A= $subjectTokenTypeB= $subjectTokenType ne "access_token"
ABresult
0X0
100
111
45 0 $self->logger->error("Given token isn't declared as access_token");
46 0 return 0;
47 }
48  
49 0 my $accessTokenSession = $self->oidc->getAccessToken($subjectToken);
50 0 ▶ unless ($accessTokenSession) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($accessTokenSession) 0 0 0
51 0 $self->logger->debug("Unable to validate subject_token $subjectToken");
52 0 return 0;
53 }
54  
55 0 ▶ unless ( $rp eq $accessTokenSession->data->{rp} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rp eq $accessTokenSession->data->{"rp"}) 0 0 0
56 $self->logger->debug( "subject_token rp isn't $rp ("
57 . $accessTokenSession->data->{rp}
58 0 . ')s' );
59 0 return 0;
60 }
61  
62 0 my $id = $accessTokenSession->data->{user_session_id};
63 0 my $session = $self->p->getApacheSession($id);
64 0 return $session->data->{ $self->conf->{whatToTrace} };
65 }
66  
67 1 1;
« blib/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Lib/2fDevices.pm »