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

filter: Statementstmt 38.2% 13 / 34 Branchbran 6.2% 1 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 3 totaltotal 26.5% 17 / 64 CC 10 SCAR 30.2
CC
10
Cov
26%
adminTokenRevoke
30.0
ssoLogout
30.0
init
2.0
CRAP 20.5
« blib/lib/Lemonldap/NG/Portal/Lib/SOAPProxy.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/2F/Register/Base.pm »
1 package Lemonldap::NG::Portal::Plugins::AdminLogout;
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::OIDCPlugin';
7  
8 1 our $VERSION = '2.23.4';
9  
10 1 ▶sub init {
Subroutine init: called CC=2 SCAR=7.0
Pod undocumented
11 1 my ($self) = @_;
12  
13 1 ▶ return unless $self->SUPER::init;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::init 0 1 1
14  
15 1 $self->addUnauthRoute( admintokenrevoke => 'adminTokenRevoke', ['POST'] );
16 1 1;
17 }
18  
19 0 ▶sub adminTokenRevoke {
Subroutine adminTokenRevoke: not called CC=5 SCAR=34.0
Pod undocumented
20 0 my ( $self, $req ) = @_;
21 0 my $auth = $req->env->{HTTP_AUTHORIZATION};
22 0 ▶ unless ($auth
Branch: 1 branch
BranchTrueFalseTotal
unless ($auth and $auth eq 'Bearer ' . $self->conf->{"adminLogoutServerSecret"}) 0 0 0
Condition0%0/3
$auth and $auth eq 'Bearer ' . $self->conf->{"adminLogoutServerSecret"}
!ll&&!rl&&r
000
MC/DC0%0/2
$auth and $auth eq 'Bearer ' . $self->conf->{"adminLogoutServerSecret"}
$auth $auth eq 'Bearer ' . $self->conf->{"adminLogoutServerSecret"}
Truth table0%0/3
A and B
A= $authB= $auth eq 'Bearer ' . $self->conf->{"adminLogoutServerSecret"}
ABresult
0X0
100
111
23 and $auth eq "Bearer " . $self->conf->{adminLogoutServerSecret} )
24 {
25 0 return $self->p->sendError( $req, 'Bad credentials', 401 );
26 }
27  
28 0 my $type = $req->param('token_hint');
29 0 ▶ if ( $type eq 'SSO' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "SSO") 0 0 0
30 0 return $self->ssoLogout($req);
31 }
32  
33 0 ▶ if ( $type =~ /^(?:refresh|access)_token$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^(?:refresh|access)_token$/) 0 0 0
34 return $self->oidc->_revokeToken(
35 $req,
36 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 0 my ($session) = @_;
38 return (
39 $self->oidc->getRP( $session->data->{client_id} ),
40 $session->data->{ $self->conf->{whatToTrace} }
41 0 );
42 },
43 0 'OIDCTokenRevokeServer',
44 $req->param('raw'),
45 );
46 }
47  
48 0 return $self->sendError( $req, "Unknown token_hint '$type'", 400 );
49 }
50  
51 0 ▶sub ssoLogout {
Subroutine ssoLogout: not called CC=5 SCAR=34.0
Pod undocumented
52 0 my ( $self, $req ) = @_;
53 0 ▶ my $id = $req->param('token')
Branch: 1 branch
BranchTrueFalseTotal
my $id = $req->param("token") or return $self->sendError($req, "Missing token", 400) 0 0 0
54 or return $self->sendError( $req, 'Missing token', 400 );
55  
56 # Like for tokens, the caller may give a storage identifier instead of a
57 # session one. This is what the Manager does, since it collects sessions
58 # using searchOn()
59 0 my $raw = $req->param('raw');
60  
61 0 ▶ my $session =
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 0 0
62 $self->p->getApacheSession( $id, ( $raw ? ( hashStore => 0 ) : () ) );
63 0 ▶ unless ($session) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($session) 0 0 0
64 0 return $self->sendError( $req, "Session $id not found", 400 );
65 }
66  
67 0 $req->userData( $req->sessionInfo( $session->data ) );
68 return $self->p->do(
69 $req,
70 [
71 0 ▶ @{ $self->p->beforeLogout },
Branch: 1 branch
BranchTrueFalseTotal
$raw ? : 0 0 0
72 'authLogout',
73 ( $raw ? [ 'deleteSession', rawSessionId => 1 ] : 'deleteSession' ),
74 ]
75 );
76 }
77  
78 1 1;
« blib/lib/Lemonldap/NG/Portal/Lib/SOAPProxy.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/2F/Register/Base.pm »