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;
|
2018-10-03 22:22:15 +02:00
|
|
|
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_MUSTAUTHN);
|
2018-10-03 21:07:10 +02:00
|
|
|
|
2020-02-25 22:01:04 +01:00
|
|
|
our $VERSION = '2.0.8';
|
2018-10-03 21:07:10 +02:00
|
|
|
|
|
|
|
extends 'Lemonldap::NG::Portal::Main::Plugin';
|
|
|
|
|
|
|
|
# INITIALIZATION
|
|
|
|
|
|
|
|
use constant forAuthUser => 'run';
|
|
|
|
|
2018-10-12 10:04:03 +02:00
|
|
|
sub init { 1 }
|
2018-10-03 21:07:10 +02:00
|
|
|
|
|
|
|
# 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;
|