blib/lib/Lemonldap/NG/Portal/Auth/REST.pm

filter: Statementstmt 34.8% 15 / 43 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 4 totaltotal 28.5% 20 / 70 CC 10 SCAR 36.2
CC
10
Cov
28%
authenticate
72.0
setAuthSessionInfo
6.0
init
2.3
CRAP 37.4
« blib/lib/Lemonldap/NG/Portal/2F/Yubikey.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/CDC.pm »
1 package Lemonldap::NG::Portal::Auth::REST;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Lemonldap::NG::Portal::Main::Constants qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
6 PE_OK
7 PE_ERROR
8 PE_BADCREDENTIALS
9 2 );
10  
11 2 our $VERSION = '2.23.0';
12  
13 2 extends qw(
14 Lemonldap::NG::Portal::Auth::_WebForm
15 Lemonldap::NG::Portal::Lib::REST
16 );
17  
18 # INITIALIZATION
19 1 ▶sub init {
Subroutine init: called CC=2 SCAR=8.4
Pod undocumented
20 1 my $self = shift;
21  
22 1 ▶ if ( not $self->initNamedCallFromConf( 'restAuth', 'auth' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->initNamedCallFromConf("restAuth", "auth")) 0 1 1
23 0 $self->logger->error('No REST Authentication URL given');
24 0 return 0;
25 }
26  
27 1 return $self->Lemonldap::NG::Portal::Auth::_WebForm::init();
28 }
29  
30 0 ▶sub authenticate {
Subroutine authenticate: not called CC=8 SCAR=42.8
Pod undocumented
31 0 my ( $self, $req ) = @_;
32 0 my $res = eval {
33 $self->restNamedCall( $req,
34 'auth', { user => $req->user, password => $req->data->{password} },
35 0 {} );
36 };
37 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
38 0 $self->logger->error("Auth error: $@");
39 0 $self->setSecurity($req);
40 0 return PE_ERROR;
41 }
42 0 ▶ $self->logger->debug( "REST result:" . ( $res->{result} || 'undef' ) );
Condition0%0/2
$res->{'result'} || 'undef'
l!l
00
MC/DC0%0/1
$res->{'result'} || 'undef'
$res->{'result'}
Truth table0%0/2
A
A= $res->{'result'}
Aresult
11
00
43 0 ▶ if ( $res->{info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->{"info"}) 0 0 0
44 0 eval {
45 $self->logger->debug(" $_ => $res->{info}->{$_}")
46 0 foreach ( keys %{ $res->{info} } );
47 };
48 }
49 0 ▶ $self->logger->error( 'No "info": ' . $@ ) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
50 0 ▶ unless ( $res->{result} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->{"result"}) 0 0 0
51 0 $self->userLogger->warn(
52 "Bad credentials for " . $req->user . ' (' . $req->address . ')' );
53 0 $self->setSecurity($req);
54 0 return PE_BADCREDENTIALS;
55 }
56 0 ▶ $req->data->{restAuthInfo} = $res->{info} || {};
Condition0%0/2
$res->{'info'} || {}
l!l
00
MC/DC0%0/1
$res->{'info'} || {}
$res->{'info'}
Truth table0%0/2
A
A= $res->{'info'}
Aresult
11
00
57 0 return PE_OK;
58 }
59  
60 0 ▶sub setAuthSessionInfo {
Subroutine setAuthSessionInfo: not called CC=2 SCAR=17.9
Pod undocumented
61 0 my ( $self, $req ) = @_;
62 0 $self->SUPER::setAuthSessionInfo($req);
63 $req->sessionInfo->{$_} = $req->data->{restAuthInfo}->{$_}
64 0 foreach ( keys %{ $req->data->{restAuthInfo} } );
65 0 $req->sessionInfo->{authenticationLevel} = $self->conf->{restAuthnLevel};
66 0 return PE_OK;
67 }
68  
69 0 ▶sub authLogout {
Subroutine authLogout: not called CC=1 SCAR=6.9
Pod undocumented
70 0 return PE_OK;
71 }
72  
73 2 1;
« blib/lib/Lemonldap/NG/Portal/2F/Yubikey.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/CDC.pm »