2018-10-04 18:41:03 +02:00
|
|
|
package Lemonldap::NG::Portal::Plugins::ForceAuthn;
|
2018-10-03 21:07:10 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
2020-10-09 22:26:00 +02:00
|
|
|
use Lemonldap::NG::Portal::Main::Constants qw(
|
|
|
|
PE_OK
|
|
|
|
PE_MUSTAUTHN
|
|
|
|
);
|
2018-10-03 21:07:10 +02:00
|
|
|
|
2021-10-29 23:00:05 +02:00
|
|
|
our $VERSION = '2.0.14';
|
2018-10-03 21:07:10 +02:00
|
|
|
|
|
|
|
extends 'Lemonldap::NG::Portal::Main::Plugin';
|
|
|
|
|
|
|
|
# INITIALIZATION
|
|
|
|
|
|
|
|
use constant forAuthUser => 'run';
|
|
|
|
|
|
|
|
# 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}/ )
|
|
|
|
{
|
2020-02-25 22:01:04 +01:00
|
|
|
my $delta = time - $req->{sessionInfo}->{_utime};
|
2018-10-03 21:07:10 +02:00
|
|
|
$self->logger->debug( "Delta with last Authn -> " . $delta );
|
2018-10-03 22:22:15 +02:00
|
|
|
|
2020-02-25 22:01:04 +01:00
|
|
|
return $delta <= $self->conf->{portalForceAuthnInterval}
|
|
|
|
? PE_OK
|
|
|
|
: PE_MUSTAUTHN;
|
2018-10-03 21:07:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 19:36:56 +02:00
|
|
|
1;
|