blib/lib/Lemonldap/NG/Portal/Plugins/OIDC/InternalTokenExchange.pm

filter: Statementstmt 65.8% 27 / 41 Branchbran 50.0% 8 / 16 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 56.4% 44 / 78 CC 12 SCAR 24.5
CC
12
Cov
58%
validateAudience
16.7
getUid
7.7
BEGIN
1.0
CRAP 11.6
« blib/lib/Lemonldap/NG/Portal/Auth/WebID.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/PublicNotifications.pm »
1 package Lemonldap::NG::Portal::Plugins::OIDC::InternalTokenExchange;
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.23.0';
9  
10 2 ▶sub validateAudience {
Subroutine validateAudience: called CC=8 SCAR=28.2
Pod documented
11 2 my ( $self, $req, $rp, $target, $requestedTokenType ) = @_;
12  
13 2 ▶ if ( $requestedTokenType and $requestedTokenType ne 'access_token' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($requestedTokenType and $requestedTokenType ne "access_token") 0 2 2
Condition33%1/3
$requestedTokenType and $requestedTokenType ne "access_token"
!ll&&!rl&&r
020
MC/DC0%0/2
$requestedTokenType and $requestedTokenType ne "access_token"
$requestedTokenType $requestedTokenType ne "access_token"
Truth table33%1/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 2 ▶ unless ( $target->{audience} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target->{"audience"}) 0 2 2
19 0 $target->{rp} = $rp;
20 0 return 1;
21 }
22  
23 2 ▶ unless ( $target->{rp} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target->{"rp"}) 0 2 2
24 0 $self->logger->debug(
25 "Token exchange request for an unexistent RP $target->{audience}");
26 0 return 0;
27 }
28  
29 2 ▶ return 1 if $target->{rp} eq $rp;
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"rp"} eq $rp 0 2 2
30  
31 my $list = $self->oidc->rpOptions->{ $target->{rp} }
32 2 ->{oidcRPMetaDataOptionsTokenXAuthorizedRP};
33 2 ▶ unless ( $list and grep { $_ eq $rp } split /[,;\s]+/, $list ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)) 0 2 2
Condition33%1/3
$list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
!ll&&!rl&&r
002
MC/DC0%0/2
$list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
$list grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
Truth table33%1/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 2 return 1;
39 }
40  
41 2 ▶sub getUid {
Subroutine getUid: called CC=5 SCAR=20.5
Pod documented
42 2 my ( $self, $req, $rp, $subjectToken, $subjectTokenType ) = @_;
43  
44 2 ▶ if ( $subjectTokenType and $subjectTokenType ne 'access_token' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subjectTokenType and $subjectTokenType ne "access_token") 0 2 2
Condition33%1/3
$subjectTokenType and $subjectTokenType ne "access_token"
!ll&&!rl&&r
020
MC/DC0%0/2
$subjectTokenType and $subjectTokenType ne "access_token"
$subjectTokenType $subjectTokenType ne "access_token"
Truth table33%1/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 2 my $accessTokenSession = $self->oidc->getAccessToken($subjectToken);
50 2 ▶ unless ($accessTokenSession) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($accessTokenSession) 0 2 2
51 0 $self->logger->debug("Unable to validate subject_token $subjectToken");
52 0 return 0;
53 }
54  
55 2 ▶ unless ( $rp eq $accessTokenSession->data->{rp} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rp eq $accessTokenSession->data->{"rp"}) 0 2 2
56 $self->logger->debug( "subject_token rp isn't $rp ("
57 . $accessTokenSession->data->{rp}
58 0 . ')s' );
59 0 return 0;
60 }
61  
62 2 my $id = $accessTokenSession->data->{user_session_id};
63 2 my $session = $self->p->getApacheSession($id);
64 2 return $session->data->{ $self->conf->{whatToTrace} };
65 }
66  
67 package Lemonldap::NG::Portal::Plugins::OIDCInternalTokenExchange;
68  
69 1 our @ISA = ('Lemonldap::NG::Portal::Plugins::OIDC::InternalTokenExchange');
70  
71 1 1;
« blib/lib/Lemonldap/NG/Portal/Auth/WebID.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Plugins/PublicNotifications.pm »