blib/lib/Lemonldap/NG/Manager/2ndFA.pm

filter: Statementstmt 100% 55 / 55 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 4 totaltotal 83.5% 76 / 91 CC 9 SCAR 10.0
CC
9
Cov
89%
init
5.3
del2F
4.2
sfa
2.0
CRAP 2.7
« blib/lib/Lemonldap/NG/Manager/Api/Common.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Api.pm »
1 package Lemonldap::NG::Manager::2ndFA;
2  
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 28 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 28 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 28 ▶use Lemonldap::NG::Common::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 28 ▶use Lemonldap::NG::Common::Conf::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 28 ▶use Lemonldap::NG::Common::PSGI::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 28 ▶use Lemonldap::NG::Common::Conf::ReConstants;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 28 extends qw(
13 Lemonldap::NG::Manager::Plugin
14 Lemonldap::NG::Common::Session::REST
15 Lemonldap::NG::Common::Conf::AccessLib
16 );
17  
18 28 our $VERSION = '2.18.0';
19  
20 #############################
21 # I. INITIALIZATION METHODS #
22 #############################
23  
24 28 ▶use constant defaultRoute => '2ndfa.html';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 28 ▶use constant icon => 'wrench';
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 45 ▶sub init {
Subroutine init: called CC=5 SCAR=16.6
Pod undocumented
28 45 my ( $self, $conf ) = @_;
29  
30 # Remote Procedure are defined in Lemonldap::NG::Common::Session::REST
31 # HTML template
32 45 $self->addRoute( '2ndfa.html', 'sfaView', ['GET'] )
33  
34 ->addRoute(
35 sfa => { ':sessionType' => 'sfa' },
36 ['GET']
37 )
38  
39 # DELETE 2FA DEVICE
40 ->addRoute(
41 sfa => { ':sessionType' => { ':sessionId' => 'del2F' } },
42 ['DELETE']
43 );
44  
45 45 $self->setTypes($conf);
46 45 ▶ $self->{multiValuesSeparator} ||= '; ';
Condition50%1/2
$self->{"multiValuesSeparator"} ||= "; "
l!l
045
MC/DC0%0/1
$self->{"multiValuesSeparator"} ||= "; "
$self->{"multiValuesSeparator"}
Truth table50%1/2
A
A= $self->{"multiValuesSeparator"}
Aresult
11
00
47 45 ▶ $self->{hiddenAttributes} //= "_password";
Condition50%1/2
$self->{"hiddenAttributes"} //= "_password"
l!l
045
MC/DC0%0/1
$self->{"hiddenAttributes"} //= "_password"
$self->{"hiddenAttributes"}
Truth table50%1/2
A
A= $self->{"hiddenAttributes"}
Aresult
11
00
48 $self->{hiddenAttributes} .= ' _session_id'
49 45 ▶ unless $conf->{displaySessionId};
Branch: 1 branch
BranchTrueFalseTotal
unless $conf->{"displaySessionId"} 0 45 45
50  
51 $self->{regSfaTypes} = [ (
52 180 sort map { s/^Yubikey$/UBK/r } split /[\s,]+/,
53 $conf->{available2FSelfRegistration}
54 ),
55 45 ▶ keys %{ $conf->{sfExtra} || {} },
Condition50%1/2
$conf->{'sfExtra'} || {}
l!l
045
MC/DC0%0/1
$conf->{'sfExtra'} || {}
$conf->{'sfExtra'}
Truth table50%1/2
A
A= $conf->{'sfExtra'}
Aresult
11
00
56 ];
57 45 return 1;
58 }
59  
60 ###################
61 # II. 2FA METHODS #
62 ###################
63  
64 9 ▶sub del2F {
Subroutine del2F: called CC=4 SCAR=14.3
Pod undocumented
65  
66 9 my ( $self, $req, $session, $skey ) = @_;
67  
68 9 ▶ my $mod = $self->getMod($req)
Branch: 1 branch
BranchTrueFalseTotal
my $mod = $self->getMod($req) or return $self->sendError($req, "Bad mode", 400) 9 0 9
69 or return $self->sendError( $req, 'Bad mode', 400 );
70  
71 9 my $params = $req->parameters();
72 my $type = $params->{type}
73 9 ▶ or return $self->sendError( $req, 'Missing "type" parameter', 400 );
Branch: 1 branch
BranchTrueFalseTotal
my $type = $params->{"type"} or return $self->sendError($req, "Missing \"type\" parameter", 400) 9 0 9
74 my $epoch = $params->{epoch}
75 9 ▶ or return $self->sendError( $req, 'Missing "epoch" parameter', 400 );
Branch: 1 branch
BranchTrueFalseTotal
my $epoch = $params->{"epoch"} or return $self->sendError($req, "Missing \"epoch\" parameter", 400) 9 0 9
76  
77 9 $self->logger->debug(
78 "Call procedure delete2F with type=$type and epoch=$epoch");
79 9 return $self->delete2F( $req, $session, $skey );
80 }
81  
82 ########################
83 # III. DISPLAY METHODS #
84 ########################
85  
86 12 ▶sub sfa {
Subroutine sfa: called CC=2 SCAR=7.0
Pod undocumented
87 12 my ( $self, $req, $session, $skey ) = @_;
88  
89 12 ▶ my $mod = $self->getMod($req)
Branch: 1 branch
BranchTrueFalseTotal
my $mod = $self->getMod($req) or return $self->sendError($req, "Bad mode", 400) 12 0 12
90 or return $self->sendError( $req, 'Bad mode', 400 );
91  
92 12 $self->logger->debug("Call procedure get2F");
93 12 return $self->get2F( $req, $session, $skey );
94 }
95  
96 1 ▶sub sfaView {
Subroutine sfaView: called CC=1 SCAR=0.0
Pod undocumented
97 1 my ( $self, $req ) = @_;
98 return $self->p->sendHtml(
99 $req, "2ndfa",
100 params => {
101 1 SFATYPES => [ map { { SFATYPE => $_ } } @{ $self->{regSfaTypes} } ],
102 }
103 );
104 }
105  
106 28 1;
« blib/lib/Lemonldap/NG/Manager/Api/Common.pm ↑ Summary blib/lib/Lemonldap/NG/Manager/Api.pm »