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

35 lines
694 B
Perl
Raw Normal View History

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