| 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
| |||||||||||||
| 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
| |||||||||||||
| 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'
MC/DC0%0/1
$res->{'result'} || 'undef'
$res->{'result'}
Truth table0%0/2
A
A= $res->{'result'}
| |||||||||||||
| 43 | 0 | ▶ | if ( $res->{info} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 50 | 0 | ▶ | unless ( $res->{result} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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'} || {}
MC/DC0%0/1
$res->{'info'} || {}
$res->{'info'}
Truth table0%0/2
A
A= $res->{'info'}
| |||||||||||||
| 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; | |||||||||||