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

filter: Statementstmt 41.9% 13 / 31 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 3 totaltotal 30.9% 17 / 55 CC 7 SCAR 26.5
CC
7
Cov
32%
adminTokenRevoke
30.0
ssoLogout
6.0
init
2.0
CRAP 14.2
« blib/lib/Lemonldap/NG/Portal/Auth/WebAuthn.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Plugins.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.0';
9  
10 sub init {
11 1 ▶ my ($self) = @_;
Subroutine init: called CC=2 SCAR=7.0
Pod undocumented
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 sub adminTokenRevoke {
20 0 ▶ my ( $self, $req ) = @_;
Subroutine adminTokenRevoke: not called CC=5 SCAR=34.0
Pod undocumented
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 sub {
37 0 ▶ my ($session) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 sub ssoLogout {
52 0 ▶ my ( $self, $req ) = @_;
Subroutine ssoLogout: not called CC=2 SCAR=17.9
Pod undocumented
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 0 my $sessionData = $self->p->HANDLER->retrieveSession( $req, $id );
56 0 $req->userData( $req->sessionInfo($sessionData) );
57 return $self->p->do( $req,
58 0 [ @{ $self->p->beforeLogout }, 'authLogout', 'deleteSession' ] );
59 }
60  
61 1 1;
« blib/lib/Lemonldap/NG/Portal/Auth/WebAuthn.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Plugins.pm »