WIP - Append PortalForceAuthn plugin (#1507)

This commit is contained in:
Christophe Maudoux 2018-10-03 22:22:15 +02:00
parent 6837304f9b
commit a82939ee4b
3 changed files with 44 additions and 4 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -0,0 +1,20 @@
<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">