« 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
Condition33%1/3
$requestedTokenType and $requestedTokenType ne "access_token"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 19 | 0 | $target->{rp} = $rp; | |||||||||||||||||||||||||||
| 20 | 0 | return 1; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | unless ( $target->{rp} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$list and grep {$_ eq $rp;} split(/[,;\s]+/, $list, 0)
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)
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$subjectTokenType and $subjectTokenType ne "access_token"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||