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

filter: Statementstmt 44.7% 17 / 38 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 3 totaltotal 34.3% 22 / 64 CC 7 SCAR 25.2
CC
7
Cov
35%
adminTokenRevoke
30.0
ssoLogout
6.0
init
2.2
CRAP 12.4
« blib/lib/Lemonldap/NG/Portal/2F/Register/Base.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/2F/TOTP.pm »
1 package Lemonldap::NG::Portal::Plugins::AdminLogout;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Lemonldap::NG::Portal::Issuer::OpenIDConnect;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 extends 'Lemonldap::NG::Portal::Main::Plugin';
8  
9 1 our $VERSION = '2.22.0';
10  
11 has oidc => (
12 is => 'ro',
13 lazy => 1,
14 default => sub {
15 $_[0]
16 0 ▶ ->p->loadedModules->{'Lemonldap::NG::Portal::Issuer::OpenIDConnect'};
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 }
18 1 );
19  
20 sub init {
21 1 ▶ my ($self) = @_;
Subroutine init: called CC=2 SCAR=7.9
Pod undocumented
22 1 ▶ unless ( $self->conf->{issuerDBOpenIDConnectActivation} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->conf->{"issuerDBOpenIDConnectActivation"}) 0 1 1
23 0 $self->logger->error(
24 'This plugin can be used only if OIDC server is enabled');
25 0 return 0;
26 }
27  
28 1 $self->addUnauthRoute( admintokenrevoke => 'adminTokenRevoke', ['POST'] );
29 1 1;
30 }
31  
32 sub adminTokenRevoke {
33 0 ▶ my ( $self, $req ) = @_;
Subroutine adminTokenRevoke: not called CC=5 SCAR=34.0
Pod undocumented
34 0 my $auth = $req->env->{HTTP_AUTHORIZATION};
35 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
36 and $auth eq "Bearer " . $self->conf->{adminLogoutServerSecret} )
37 {
38 0 return $self->p->sendError( $req, 'Bad credentials', 401 );
39 }
40  
41 0 my $type = $req->param('token_hint');
42 0 ▶ if ( $type eq 'SSO' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "SSO") 0 0 0
43 0 return $self->ssoLogout($req);
44 }
45  
46 0 ▶ if ( $type =~ /^(?:refresh|access)_token$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^(?:refresh|access)_token$/) 0 0 0
47 return $self->oidc->_revokeToken(
48 $req,
49 sub {
50 0 ▶ my ($session) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 return (
52 $self->oidc->getRP( $session->data->{client_id} ),
53 $session->data->{ $self->conf->{whatToTrace} }
54 0 );
55 },
56 0 'OIDCTokenRevokeServer',
57 $req->param('raw'),
58 );
59 }
60  
61 0 return $self->sendError( $req, "Unknown token_hint '$type'", 400 );
62 }
63  
64 sub ssoLogout {
65 0 ▶ my ( $self, $req ) = @_;
Subroutine ssoLogout: not called CC=2 SCAR=17.9
Pod undocumented
66 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
67 or return $self->sendError( $req, 'Missing token', 400 );
68 0 my $sessionData = $self->p->HANDLER->retrieveSession( $req, $id );
69 0 $req->userData( $req->sessionInfo($sessionData) );
70 return $self->p->do( $req,
71 0 [ @{ $self->p->beforeLogout }, 'authLogout', 'deleteSession' ] );
72 }
73  
74 1 1;
« blib/lib/Lemonldap/NG/Portal/2F/Register/Base.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/2F/TOTP.pm »