Commit a82939ee authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

WIP - Append PortalForceAuthn plugin (#1507)

parent 6837304f
......@@ -217,6 +217,21 @@ sub display {
);
}
elsif ( $req->error == PE_MUSTAUTHN ) {
$skinfile = 'updatesession';
%templateParams = (
MSG => 'PE87',
CONFIRMKEY => $self->stamp,
PORTAL => $self->conf->{portal},
URL => $req->data->{_url},
(
$req->data->{customScript}
? ( CUSTOM_SCRIPT => $req->data->{customScript} )
: ()
),
);
}
# 2.3 Case : user authenticated but an error was returned (bad url,...)
elsif (
$req->noLoginDisplay
......
......@@ -3,7 +3,7 @@ package Lemonldap::NG::Portal::Plugins::PortalForceAuthn;
use Data::Dumper;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_MUSTREAUTHN);
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_MUSTAUTHN);
our $VERSION = '2.0.0';
......@@ -19,16 +19,21 @@ sub init {1}
sub run {
my ( $self, $req ) = @_;
my $portalURL = $self->conf->{portal};
my $HTTP_HOST = $req->env->{HTTP_HOST};
$self->logger->debug( "********* " . Dumper($req) );
my $portalURL = $self->conf->{portal} || '';
my $HTTP_HOST = $req->env->{HTTP_HOST} || '';
my $referer = $req->env->{HTTP_REFERER} || '';
$self->logger->debug( "Portal URL -> " . Dumper($portalURL) );
$self->logger->debug( "HTTP_HOST -> " . Dumper($HTTP_HOST) );
if ( $req->env->{HTTP_HOST} and $portalURL =~ qr#\Q$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_MUSTREAUTHN;
: return PE_MUSTAUTHN;
}
}
......
<TMPL_INCLUDE NAME="header.tpl">
<div id="errorcontent" class="container">
<div class="message message-positive alert"><span trspan="<TMPL_VAR NAME="MSG">"></span></div>
<form id="upgrd" action="/upgradesession" method="post" class="password" role="form">
<input type="hidden" name="confirm" value="<TMPL_VAR NAME="CONFIRMKEY">">
<input type="hidden" name="url" value="<TMPL_VAR NAME="URL">">
<div class="buttons">
<button type="submit" class="btn btn-success">
<span class="fa fa-sign-in"></span>
<span trspan="upgradeSession">Upgrade session</span>
</button>
</div>
</form>
</div>
<TMPL_INCLUDE NAME="footer.tpl">
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment