« blib/lib/Lemonldap/NG/Portal/Captcha/CaptchEtat.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/2F/Mail2F.pm »
| 1 | # Base class for auth modules that call other auth modules (Choice,...) | ||||||||||||||||||
| 2 | # | ||||||||||||||||||
| 3 | # It fakes portal object to catch entry points and load them only if underlying | ||||||||||||||||||
| 4 | # auth module is activated | ||||||||||||||||||
| 5 | package Lemonldap::NG::Portal::Lib::Wrapper; | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 27 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 27 | ▶ | use Mouse; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 27 | ▶ | use Lemonldap::NG::Portal::Main::Constants qw(PE_OK); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | 27 | our $VERSION = '2.18.0'; | |||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 27 | extends 'Lemonldap::NG::Portal::Main::Auth'; | |||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | 122 | ▶ | has availableModules => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | # Wrappers for portal entry points: entry points are enabled only for active | ||||||||||||||||||
| 18 | # authentication module | ||||||||||||||||||
| 19 | # | ||||||||||||||||||
| 20 | # Note that "beforeAuth" can't be used here and must be wrapped in auth | ||||||||||||||||||
| 21 | # module | ||||||||||||||||||
| 22 | # | ||||||||||||||||||
| 23 | # Note also that auth module must store in $req->data->{enabledMods} a ref | ||||||||||||||||||
| 24 | # to each enabled underlying auth modules | ||||||||||||||||||
| 25 | 122 | ▶ | sub betweenAuthAndData { '_betweenAuthAndData' } | ||||||||||||||||
|
Subroutine
betweenAuthAndData: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 26 | 122 | ▶ | sub afterData { '_afterData' } | ||||||||||||||||
|
Subroutine
afterData: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 27 | 122 | ▶ | sub endAuth { '_endAuth' } | ||||||||||||||||
|
Subroutine
endAuth: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 28 | 122 | ▶ | sub forAuthUser { '_forAuthUser' } | ||||||||||||||||
|
Subroutine
forAuthUser: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 29 | 122 | ▶ | sub beforeLogout { '_beforeLogout' } | ||||||||||||||||
|
Subroutine
beforeLogout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 30 | 122 | ▶ | sub authCancel { '_authCancel' } | ||||||||||||||||
|
Subroutine
authCancel: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 52 | ▶ | sub _betweenAuthAndData { _wrapEntryPoint( @_, 'betweenAuthAndData' ); } | ||||||||||||||||
|
Subroutine
_betweenAuthAndData: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 33 | 55 | ▶ | sub _afterData { _wrapEntryPoint( @_, 'afterData' ); } | ||||||||||||||||
|
Subroutine
_afterData: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 34 | 52 | ▶ | sub _endAuth { _wrapEntryPoint( @_, 'endAuth' ); } | ||||||||||||||||
|
Subroutine
_endAuth: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 35 | 8 | ▶ | sub _forAuthUser { _wrapEntryPoint( @_, 'forAuthUser', 1 ); } | ||||||||||||||||
|
Subroutine
_forAuthUser: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 36 | 33 | ▶ | sub _beforeLogout { _wrapEntryPoint( @_, 'beforeLogout', 1 ); } | ||||||||||||||||
|
Subroutine
_beforeLogout: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 37 | 2 | ▶ | sub _authCancel { _wrapEntryPoint( @_, 'authCancel' ); } | ||||||||||||||||
|
Subroutine
_authCancel: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 202 | ▶ | sub _wrapEntryPoint { | ||||||||||||||||
|
Subroutine
_wrapEntryPoint: called CC=11 SCAR=25.3
| |||||||||||||||||||
| 40 | 202 | my ( $self, $req, $name, $connected ) = @_; | |||||||||||||||||
| 41 | 202 | my @t; | |||||||||||||||||
| 42 | 202 | ▶ | if ($connected) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 43 | 41 | ▶ | if ( my $mod = $req->userData->{ $self->sessionKey } ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 44 | 37 | ▶ | if ( $self->modules->{$mod} ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 45 | 37 | @t = ( $self->modules->{$mod} ); | |||||||||||||||||
| 46 | } | ||||||||||||||||||
| 47 | else { | ||||||||||||||||||
| 48 | 0 | $self->userLogger->error( | |||||||||||||||||
| 49 | "Bad $self->{sessionKey} value in session ($name)"); | ||||||||||||||||||
| 50 | } | ||||||||||||||||||
| 51 | } | ||||||||||||||||||
| 52 | else { | ||||||||||||||||||
| 53 | 4 | $self->userLogger->warn( | |||||||||||||||||
| 54 | "Missing $self->{sessionKey} key in session"); | ||||||||||||||||||
| 55 | } | ||||||||||||||||||
| 56 | } | ||||||||||||||||||
| 57 | elsif ( my $mod = $req->sessionInfo->{ $self->sessionKey } ) { | ||||||||||||||||||
| 58 | 147 | ▶ | if ( $self->modules->{$mod} ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 59 | 147 | @t = ( $self->modules->{$mod} ); | |||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | else { | ||||||||||||||||||
| 62 | 0 | $self->userLogger->error( | |||||||||||||||||
| 63 | "Bad $self->{sessionKey} value in session ($name)"); | ||||||||||||||||||
| 64 | } | ||||||||||||||||||
| 65 | } | ||||||||||||||||||
| 66 | elsif ( ref $req->data->{ "enabledMods" . $self->type } ) { | ||||||||||||||||||
| 67 | 0 | @t = @{ $req->data->{ "enabledMods" . $self->type } }; | |||||||||||||||||
| 68 | } | ||||||||||||||||||
| 69 | else { | ||||||||||||||||||
| 70 | 14 | $self->logger->debug( | |||||||||||||||||
| 71 | "Unable to find enabledMods$self->{type} in this context: $name"); | ||||||||||||||||||
| 72 | } | ||||||||||||||||||
| 73 | 202 | foreach (@t) { | |||||||||||||||||
| 74 | 184 | ▶ | if ( $_->can($name) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | # Launch sub and break loop if result isn't PE_OK (==0) | ||||||||||||||||||
| 77 | 2 | ▶ | if ( my $sub = $_->$name() ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 78 | 2 | my $res = $_->$sub($req); | |||||||||||||||||
| 79 | 2 | ▶ | return $res if ($res); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 80 | } | ||||||||||||||||||
| 81 | } | ||||||||||||||||||
| 82 | } | ||||||||||||||||||
| 83 | 200 | return PE_OK; | |||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | 9 | ▶ | sub AUTOLOAD { | ||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.2
| |||||||||||||||||||
| 87 | 27 | ▶ | no strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | # Unknown methods are tried with real portal | ||||||||||||||||||
| 90 | 9 | my $self = shift; | |||||||||||||||||
| 91 | 9 | my $sub = $AUTOLOAD; | |||||||||||||||||
| 92 | 9 | $sub =~ s/.*:://; | |||||||||||||||||
| 93 | 9 | ▶ | if ( $self->p->can($sub) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 94 | 9 | return $self->p->$sub(@_); | |||||||||||||||||
| 95 | } | ||||||||||||||||||
| 96 | 0 | require Carp; | |||||||||||||||||
| 97 | 0 | Carp::confess "Unknown method $sub"; | |||||||||||||||||
| 98 | } | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 27 | 1; | |||||||||||||||||