lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ForceAuthn.pm
Clément OUDOT c5f9a7f95b make tidy
2018-10-12 10:04:03 +02:00

34 lines
712 B
Perl

package Lemonldap::NG::Portal::Plugins::ForceAuthn;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_MUSTAUTHN);
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Portal::Main::Plugin';
# INITIALIZATION
use constant forAuthUser => 'run';
sub init { 1 }
# RUNNING METHOD
sub run {
my ( $self, $req ) = @_;
if ( $req->env->{HTTP_HOST}
and $self->conf->{portal} =~ /\Q$req->{env}->{HTTP_HOST}/ )
{
my $delta = time() - $req->{sessionInfo}->{_utime};
$self->logger->debug( "Delta with last Authn -> " . $delta );
$delta <= $self->conf->{portalForceAuthnInterval}
? return PE_OK
: return PE_MUSTAUTHN;
}
}
1;