lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ForceAuthn.pm

34 lines
712 B
Perl
Raw Normal View History

2018-10-04 18:41:03 +02:00
package Lemonldap::NG::Portal::Plugins::ForceAuthn;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_MUSTAUTHN);
2019-02-12 18:21:38 +01:00
our $VERSION = '2.1.0';
extends 'Lemonldap::NG::Portal::Main::Plugin';
# INITIALIZATION
use constant forAuthUser => 'run';
2018-10-12 10:04:03 +02:00
sub init { 1 }
# RUNNING METHOD
sub run {
my ( $self, $req ) = @_;
2018-10-05 19:36:56 +02:00
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}
2018-10-12 10:04:03 +02:00
? return PE_OK
: return PE_MUSTAUTHN;
}
}
2018-10-05 19:36:56 +02:00
1;