« blib/lib/Lemonldap/NG/Portal/Plugins/CrowdSecAgent.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Lib/CAS.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( | |||||||||||
| 6 | PE_OK | ||||||||||||
| 7 | PE_ERROR | ||||||||||||
| 8 | PE_BADCREDENTIALS | ||||||||||||
| 9 | 2 | ▶ | ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 2 | our $VERSION = '2.0.12'; | |||||||||||
| 12 | |||||||||||||
| 13 | 2 | extends qw( | |||||||||||
| 14 | Lemonldap::NG::Portal::Auth::_WebForm | ||||||||||||
| 15 | Lemonldap::NG::Portal::Lib::REST | ||||||||||||
| 16 | ); | ||||||||||||
| 17 | |||||||||||||
| 18 | # INITIALIZATION | ||||||||||||
| 19 | |||||||||||||
| 20 | sub init { | ||||||||||||
| 21 | 1 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
init: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||
| 22 | |||||||||||||
| 23 | # Add warning in log | ||||||||||||
| 24 | 1 | ▶ | unless ( $self->conf->{restAuthUrl} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 0 | $self->logger->error('No REST Authentication URL given'); | |||||||||||
| 26 | 0 | return 0; | |||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 1 | return $self->Lemonldap::NG::Portal::Auth::_WebForm::init(); | |||||||||||
| 30 | } | ||||||||||||
| 31 | |||||||||||||
| 32 | sub authenticate { | ||||||||||||
| 33 | 0 | ▶ | my ( $self, $req ) = @_; | ||||||||||
|
Subroutine
authenticate: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||
| 34 | 0 | my $res = eval { | |||||||||||
| 35 | $self->restCall( $self->conf->{restAuthUrl}, | ||||||||||||
| 36 | 0 | { user => $req->user, password => $req->data->{password} } ); | |||||||||||
| 37 | }; | ||||||||||||
| 38 | 0 | ▶ | if ($@) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | 0 | $self->logger->error("Auth error: $@"); | |||||||||||
| 40 | 0 | $self->setSecurity($req); | |||||||||||
| 41 | 0 | return PE_ERROR; | |||||||||||
| 42 | } | ||||||||||||
| 43 | 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'}
| |||||||||||||
| 44 | 0 | ▶ | if ( $res->{info} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 0 | eval { | |||||||||||
| 46 | $self->logger->debug(" $_ => $res->{info}->{$_}") | ||||||||||||
| 47 | 0 | foreach ( keys %{ $res->{info} } ); | |||||||||||
| 48 | }; | ||||||||||||
| 49 | } | ||||||||||||
| 50 | 0 | ▶ | $self->logger->error( 'No "info": ' . $@ ) if ($@); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 0 | ▶ | unless ( $res->{result} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 0 | $self->userLogger->warn( | |||||||||||
| 53 | "Bad credentials for " . $req->user . ' (' . $req->address . ')' ); | ||||||||||||
| 54 | 0 | $self->setSecurity($req); | |||||||||||
| 55 | 0 | return PE_BADCREDENTIALS; | |||||||||||
| 56 | } | ||||||||||||
| 57 | 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'}
| |||||||||||||
| 58 | 0 | return PE_OK; | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | sub setAuthSessionInfo { | ||||||||||||
| 62 | 0 | ▶ | my ( $self, $req ) = @_; | ||||||||||
|
Subroutine
setAuthSessionInfo: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 63 | 0 | $self->SUPER::setAuthSessionInfo($req); | |||||||||||
| 64 | $req->sessionInfo->{$_} = $req->data->{restAuthInfo}->{$_} | ||||||||||||
| 65 | 0 | foreach ( keys %{ $req->data->{restAuthInfo} } ); | |||||||||||
| 66 | 0 | $req->sessionInfo->{authenticationLevel} = $self->conf->{restAuthnLevel}; | |||||||||||
| 67 | 0 | return PE_OK; | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | sub authLogout { | ||||||||||||
| 71 | 0 | ▶ | return PE_OK; | ||||||||||
|
Subroutine
authLogout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 72 | } | ||||||||||||
| 73 | |||||||||||||
| 74 | 2 | 1; | |||||||||||