Partial revert - Modify Portal side is more consistent (#1653)
This commit is contained in:
parent
8ccb4571d3
commit
063c0f0d1b
|
@ -241,13 +241,7 @@ sub sendHtml {
|
||||||
$args{code} ||= 200;
|
$args{code} ||= 200;
|
||||||
$args{headers} ||= $req->respHeaders || [];
|
$args{headers} ||= $req->respHeaders || [];
|
||||||
my $htpl;
|
my $htpl;
|
||||||
my $tmpl = $template;
|
|
||||||
$template = ( $args{templateDir} // $self->templateDir ) . "/$template.tpl";
|
$template = ( $args{templateDir} // $self->templateDir ) . "/$template.tpl";
|
||||||
unless (-f $template){
|
|
||||||
$self->logger->debug("$template NOT found!!!");
|
|
||||||
$template = $self->conf->{templateDir} . '/bootstrap/' . "$tmpl.tpl";
|
|
||||||
$self->logger->debug("-> Try to load $template");
|
|
||||||
}
|
|
||||||
return $self->sendError( $req, "Unable to read $template", 500 )
|
return $self->sendError( $req, "Unable to read $template", 500 )
|
||||||
unless ( -r $template and -f $template );
|
unless ( -r $template and -f $template );
|
||||||
eval {
|
eval {
|
||||||
|
|
|
@ -17,11 +17,11 @@ use strict;
|
||||||
use URI::Escape;
|
use URI::Escape;
|
||||||
|
|
||||||
# List constants
|
# List constants
|
||||||
sub authProcess { qw(extractFormInfo getUser authenticate) }
|
sub authProcess {qw(extractFormInfo getUser authenticate)}
|
||||||
|
|
||||||
sub sessionData {
|
sub sessionData {
|
||||||
qw(setAuthSessionInfo setSessionInfo setMacros setGroups setPersistentSessionInfo
|
qw(setAuthSessionInfo setSessionInfo setMacros setGroups setPersistentSessionInfo
|
||||||
setLocalGroups store secondFactor);
|
setLocalGroups store secondFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub validSession {
|
sub validSession {
|
||||||
|
@ -56,11 +56,9 @@ sub handler {
|
||||||
if ( $sp or %{ $req->pdata } ) {
|
if ( $sp or %{ $req->pdata } ) {
|
||||||
my %v = (
|
my %v = (
|
||||||
name => $self->conf->{cookieName} . 'pdata',
|
name => $self->conf->{cookieName} . 'pdata',
|
||||||
(
|
( %{ $req->pdata }
|
||||||
%{ $req->pdata }
|
|
||||||
? ( value => uri_escape( JSON::to_json( $req->pdata ) ) )
|
? ( value => uri_escape( JSON::to_json( $req->pdata ) ) )
|
||||||
: (
|
: ( value => '',
|
||||||
value => '',
|
|
||||||
expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
|
expires => 'Wed, 21 Oct 2015 00:00:00 GMT'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -94,8 +92,7 @@ sub login {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return $self->do(
|
return $self->do(
|
||||||
$req,
|
$req,
|
||||||
[
|
[ 'controlUrl', @{ $self->beforeAuth },
|
||||||
'controlUrl', @{ $self->beforeAuth },
|
|
||||||
$self->authProcess, @{ $self->betweenAuthAndData },
|
$self->authProcess, @{ $self->betweenAuthAndData },
|
||||||
$self->sessionData, @{ $self->afterData },
|
$self->sessionData, @{ $self->afterData },
|
||||||
$self->validSession, @{ $self->endAuth },
|
$self->validSession, @{ $self->endAuth },
|
||||||
|
@ -107,8 +104,7 @@ sub postLogin {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return $self->do(
|
return $self->do(
|
||||||
$req,
|
$req,
|
||||||
[
|
[ 'restoreArgs', 'controlUrl',
|
||||||
'restoreArgs', 'controlUrl',
|
|
||||||
@{ $self->beforeAuth }, $self->authProcess,
|
@{ $self->beforeAuth }, $self->authProcess,
|
||||||
@{ $self->betweenAuthAndData }, $self->sessionData,
|
@{ $self->betweenAuthAndData }, $self->sessionData,
|
||||||
@{ $self->afterData }, $self->validSession,
|
@{ $self->afterData }, $self->validSession,
|
||||||
|
@ -121,8 +117,7 @@ sub authenticatedRequest {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return $self->do(
|
return $self->do(
|
||||||
$req,
|
$req,
|
||||||
[
|
[ 'importHandlerData', 'controlUrl',
|
||||||
'importHandlerData', 'controlUrl',
|
|
||||||
'checkLogout', @{ $self->forAuthUser }
|
'checkLogout', @{ $self->forAuthUser }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -132,8 +127,7 @@ sub postAuthenticatedRequest {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return $self->do(
|
return $self->do(
|
||||||
$req,
|
$req,
|
||||||
[
|
[ 'importHandlerData', 'restoreArgs',
|
||||||
'importHandlerData', 'restoreArgs',
|
|
||||||
'controlUrl', 'checkLogout',
|
'controlUrl', 'checkLogout',
|
||||||
@{ $self->forAuthUser }
|
@{ $self->forAuthUser }
|
||||||
]
|
]
|
||||||
|
@ -150,8 +144,8 @@ sub refresh {
|
||||||
foreach ( keys %data ) {
|
foreach ( keys %data ) {
|
||||||
delete $data{$_} unless ( /^_/ or /^(?:startTime)$/ );
|
delete $data{$_} unless ( /^_/ or /^(?:startTime)$/ );
|
||||||
}
|
}
|
||||||
$req->steps( [
|
$req->steps(
|
||||||
'getUser',
|
[ 'getUser',
|
||||||
@{ $self->betweenAuthAndData },
|
@{ $self->betweenAuthAndData },
|
||||||
'setAuthSessionInfo',
|
'setAuthSessionInfo',
|
||||||
'setSessionInfo',
|
'setSessionInfo',
|
||||||
|
@ -169,21 +163,21 @@ sub refresh {
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$req->info(
|
$req->info(
|
||||||
$self->loadTemplate(
|
$self->loadTemplate(
|
||||||
'simpleInfo', params => { trspan => 'rightsReloadNeedsLogout' }
|
'simpleInfo',
|
||||||
|
params => { trspan => 'rightsReloadNeedsLogout' }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$req->urldc( $self->conf->{portal} );
|
$req->urldc( $self->conf->{portal} );
|
||||||
return $self->do( $req, [ sub { PE_INFO } ] );
|
return $self->do( $req, [ sub {PE_INFO} ] );
|
||||||
}
|
}
|
||||||
return $self->do( $req, [ sub { PE_OK } ] );
|
return $self->do( $req, [ sub {PE_OK} ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub logout {
|
sub logout {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return $self->do(
|
return $self->do(
|
||||||
$req,
|
$req,
|
||||||
[
|
[ 'controlUrl', @{ $self->beforeLogout },
|
||||||
'controlUrl', @{ $self->beforeLogout },
|
|
||||||
'authLogout', 'deleteSession'
|
'authLogout', 'deleteSession'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -200,9 +194,9 @@ sub do {
|
||||||
|
|
||||||
# Update status
|
# Update status
|
||||||
if ( my $p = $self->HANDLER->tsv->{statusPipe} ) {
|
if ( my $p = $self->HANDLER->tsv->{statusPipe} ) {
|
||||||
$p->print( ( $req->user ? $req->user : $req->address ) . ' => '
|
$p->print(( $req->user ? $req->user : $req->address ) . ' => '
|
||||||
. $req->uri
|
. $req->uri
|
||||||
. " $err\n" );
|
. " $err\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update history
|
# Update history
|
||||||
|
@ -228,16 +222,14 @@ sub do {
|
||||||
else {
|
else {
|
||||||
return $self->sendJSONresponse(
|
return $self->sendJSONresponse(
|
||||||
$req,
|
$req,
|
||||||
{
|
{ result => 1,
|
||||||
result => 1,
|
|
||||||
code => $err
|
code => $err
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (
|
if ( $err
|
||||||
$err
|
|
||||||
and $err != PE_LOGOUT_OK
|
and $err != PE_LOGOUT_OK
|
||||||
and (
|
and (
|
||||||
$err != PE_REDIRECT
|
$err != PE_REDIRECT
|
||||||
|
@ -246,7 +238,7 @@ sub do {
|
||||||
and $req->data->{redirectFormMethod} eq 'post' )
|
and $req->data->{redirectFormMethod} eq 'post' )
|
||||||
or $req->info
|
or $req->info
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
my ( $tpl, $prms ) = $self->display($req);
|
my ( $tpl, $prms ) = $self->display($req);
|
||||||
$self->logger->debug("Calling sendHtml with template $tpl");
|
$self->logger->debug("Calling sendHtml with template $tpl");
|
||||||
|
@ -264,21 +256,20 @@ sub do {
|
||||||
|
|
||||||
sub getModule {
|
sub getModule {
|
||||||
my ( $self, $req, $type ) = @_;
|
my ( $self, $req, $type ) = @_;
|
||||||
if (
|
if (my $mod = {
|
||||||
my $mod = {
|
|
||||||
auth => '_authentication',
|
auth => '_authentication',
|
||||||
user => '_userDB',
|
user => '_userDB',
|
||||||
password => '_passwordDB'
|
password => '_passwordDB'
|
||||||
}->{$type}
|
}->{$type}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( my $sub = $self->$mod->can('name') ) {
|
if ( my $sub = $self->$mod->can('name') ) {
|
||||||
return $sub->( $self->$mod, $req, $type );
|
return $sub->( $self->$mod, $req, $type );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $s = ref( $self->$mod );
|
my $s = ref( $self->$mod );
|
||||||
$s =~
|
$s
|
||||||
s/^Lemonldap::NG::Portal::(?:(?:Issuer|UserDB|Auth|Password)::)?//;
|
=~ s/^Lemonldap::NG::Portal::(?:(?:Issuer|UserDB|Auth|Password)::)?//;
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +286,7 @@ sub autoRedirect {
|
||||||
|
|
||||||
# Set redirection URL if needed
|
# Set redirection URL if needed
|
||||||
$req->{urldc} ||= $self->conf->{portal}
|
$req->{urldc} ||= $self->conf->{portal}
|
||||||
if ( $req->mustRedirect and not( $req->info ) );
|
if ( $req->mustRedirect and not( $req->info ) );
|
||||||
|
|
||||||
# Redirection should be made if urldc defined
|
# Redirection should be made if urldc defined
|
||||||
if ( $req->{urldc} ) {
|
if ( $req->{urldc} ) {
|
||||||
|
@ -305,8 +296,9 @@ sub autoRedirect {
|
||||||
$req->data->{redirectFormMethod} = "get";
|
$req->data->{redirectFormMethod} = "get";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return [ 302,
|
return [
|
||||||
[ Location => $req->{urldc}, @{ $req->respHeaders } ], [] ];
|
302, [ Location => $req->{urldc}, @{ $req->respHeaders } ], []
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my ( $tpl, $prms ) = $self->display($req);
|
my ( $tpl, $prms ) = $self->display($req);
|
||||||
|
@ -326,8 +318,8 @@ sub getApacheSession {
|
||||||
$self->logger->debug("Try to get a new $args{kind} session");
|
$self->logger->debug("Try to get a new $args{kind} session");
|
||||||
}
|
}
|
||||||
|
|
||||||
my $as = Lemonldap::NG::Common::Session->new( {
|
my $as = Lemonldap::NG::Common::Session->new(
|
||||||
storageModule => $self->conf->{globalStorage},
|
{ storageModule => $self->conf->{globalStorage},
|
||||||
storageModuleOptions => $self->conf->{globalStorageOptions},
|
storageModuleOptions => $self->conf->{globalStorageOptions},
|
||||||
cacheModule => $self->conf->{localSessionStorage},
|
cacheModule => $self->conf->{localSessionStorage},
|
||||||
cacheModuleOptions => $self->conf->{localSessionStorageOptions},
|
cacheModuleOptions => $self->conf->{localSessionStorageOptions},
|
||||||
|
@ -341,8 +333,7 @@ sub getApacheSession {
|
||||||
if ( my $err = $as->error ) {
|
if ( my $err = $as->error ) {
|
||||||
$self->lmLog(
|
$self->lmLog(
|
||||||
$err,
|
$err,
|
||||||
(
|
( $err =~ /(?:Object does not exist|Invalid session ID)/
|
||||||
$err =~ /(?:Object does not exist|Invalid session ID)/
|
|
||||||
? 'notice'
|
? 'notice'
|
||||||
: 'error'
|
: 'error'
|
||||||
)
|
)
|
||||||
|
@ -357,21 +348,19 @@ sub getApacheSession {
|
||||||
$self->logger->debug("Get session $id from Portal::Main::Run") if ($id);
|
$self->logger->debug("Get session $id from Portal::Main::Run") if ($id);
|
||||||
$self->logger->debug(
|
$self->logger->debug(
|
||||||
"Check session validity -> " . $self->conf->{timeoutActivity} . "s" )
|
"Check session validity -> " . $self->conf->{timeoutActivity} . "s" )
|
||||||
if ( $self->conf->{timeoutActivity} );
|
if ( $self->conf->{timeoutActivity} );
|
||||||
my $now = time;
|
my $now = time;
|
||||||
if (
|
if ( $id
|
||||||
$id
|
|
||||||
and defined $as->data->{_utime}
|
and defined $as->data->{_utime}
|
||||||
and (
|
and (
|
||||||
( ( $now - $as->data->{_utime} ) > $self->conf->{timeout} )
|
( ( $now - $as->data->{_utime} ) > $self->conf->{timeout} )
|
||||||
or (
|
or ( $self->conf->{timeoutActivity}
|
||||||
$self->conf->{timeoutActivity}
|
|
||||||
and $as->data->{_lastSeen}
|
and $as->data->{_lastSeen}
|
||||||
and ( ( $now - $as->data->{_lastSeen} ) >
|
and ( ( $now - $as->data->{_lastSeen} )
|
||||||
$self->conf->{timeoutActivity} )
|
> $self->conf->{timeoutActivity} )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$self->logger->debug("Session $args{kind} $id expired");
|
$self->logger->debug("Session $args{kind} $id expired");
|
||||||
return;
|
return;
|
||||||
|
@ -393,8 +382,8 @@ sub getPersistentSession {
|
||||||
|
|
||||||
$info->{_session_uid} = $uid;
|
$info->{_session_uid} = $uid;
|
||||||
|
|
||||||
my $ps = Lemonldap::NG::Common::Session->new( {
|
my $ps = Lemonldap::NG::Common::Session->new(
|
||||||
storageModule => $self->conf->{persistentStorage},
|
{ storageModule => $self->conf->{persistentStorage},
|
||||||
storageModuleOptions => $self->conf->{persistentStorageOptions},
|
storageModuleOptions => $self->conf->{persistentStorageOptions},
|
||||||
id => $pid,
|
id => $pid,
|
||||||
force => 1,
|
force => 1,
|
||||||
|
@ -435,10 +424,11 @@ sub updatePersistentSession {
|
||||||
# Return if no infos to update
|
# Return if no infos to update
|
||||||
return () unless ( ref $infos eq 'HASH' and %$infos );
|
return () unless ( ref $infos eq 'HASH' and %$infos );
|
||||||
$uid ||= $req->{sessionInfo}->{ $self->conf->{whatToTrace} }
|
$uid ||= $req->{sessionInfo}->{ $self->conf->{whatToTrace} }
|
||||||
|| $req->userData->{ $self->conf->{whatToTrace} };
|
|| $req->userData->{ $self->conf->{whatToTrace} };
|
||||||
$self->logger->debug("Found 'whatToTrace' -> $uid");
|
$self->logger->debug("Found 'whatToTrace' -> $uid");
|
||||||
unless ($uid) {
|
unless ($uid) {
|
||||||
$self->logger->debug('No uid found, skipping updatePersistentSession');
|
$self->logger->debug(
|
||||||
|
'No uid found, skipping updatePersistentSession');
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
$self->logger->debug("Update $uid persistent session");
|
$self->logger->debug("Update $uid persistent session");
|
||||||
|
@ -480,14 +470,14 @@ sub updateSession {
|
||||||
foreach ( keys %$infos ) {
|
foreach ( keys %$infos ) {
|
||||||
$self->logger->debug(
|
$self->logger->debug(
|
||||||
"Update sessionInfo $_ with " . $infos->{$_} );
|
"Update sessionInfo $_ with " . $infos->{$_} );
|
||||||
$req->{sessionInfo}->{$_} = $self->HANDLER->data->{$_} =
|
$req->{sessionInfo}->{$_} = $self->HANDLER->data->{$_}
|
||||||
$infos->{$_};
|
= $infos->{$_};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update session in global storage with _updateTime
|
# Update session in global storage with _updateTime
|
||||||
$infos->{_updateTime} = strftime( "%Y%m%d%H%M%S", localtime() );
|
$infos->{_updateTime} = strftime( "%Y%m%d%H%M%S", localtime() );
|
||||||
if ( my $apacheSession =
|
if ( my $apacheSession
|
||||||
$self->getApacheSession( $id, info => $infos ) )
|
= $self->getApacheSession( $id, info => $infos ) )
|
||||||
{
|
{
|
||||||
if ( $apacheSession->error ) {
|
if ( $apacheSession->error ) {
|
||||||
$self->logger->error("Cannot update session $id");
|
$self->logger->error("Cannot update session $id");
|
||||||
|
@ -570,10 +560,10 @@ sub isTrustedUrl {
|
||||||
|
|
||||||
sub stamp {
|
sub stamp {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $res =
|
my $res
|
||||||
$self->conf->{cipher}
|
= $self->conf->{cipher}
|
||||||
? $self->conf->{cipher}->encrypt( time() )
|
? $self->conf->{cipher}->encrypt( time() )
|
||||||
: 1;
|
: 1;
|
||||||
$res =~ s/\+/%2B/g;
|
$res =~ s/\+/%2B/g;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -705,7 +695,7 @@ sub cookie {
|
||||||
$h{path} ||= '/';
|
$h{path} ||= '/';
|
||||||
$h{HttpOnly} //= $self->conf->{httpOnly};
|
$h{HttpOnly} //= $self->conf->{httpOnly};
|
||||||
$h{max_age} //= $self->conf->{cookieExpiration}
|
$h{max_age} //= $self->conf->{cookieExpiration}
|
||||||
if ( $self->conf->{cookieExpiration} );
|
if ( $self->conf->{cookieExpiration} );
|
||||||
foreach (qw(domain path expires max_age HttpOnly)) {
|
foreach (qw(domain path expires max_age HttpOnly)) {
|
||||||
my $f = $_;
|
my $f = $_;
|
||||||
$f =~ s/_/-/g;
|
$f =~ s/_/-/g;
|
||||||
|
@ -726,16 +716,24 @@ sub _dump {
|
||||||
|
|
||||||
sub sendHtml {
|
sub sendHtml {
|
||||||
my ( $self, $req, $template, %args ) = @_;
|
my ( $self, $req, $template, %args ) = @_;
|
||||||
|
|
||||||
$args{params}->{TROVER} = $self->trOver;
|
$args{params}->{TROVER} = $self->trOver;
|
||||||
$args{templateDir} =
|
$args{templateDir}
|
||||||
$self->conf->{templateDir} . '/' . $self->getSkin($req);
|
= $self->conf->{templateDir} . '/' . $self->getSkin($req);
|
||||||
|
my $tmpl = $args{templateDir} . "/$template.tpl";
|
||||||
|
unless ( -f $tmpl ) {
|
||||||
|
$self->logger->debug("Template : $tmpl NOT found!!!");
|
||||||
|
$args{templateDir} = $self->conf->{templateDir} . '/bootstrap';
|
||||||
|
$tmpl = $args{templateDir} . "/$template.tpl";
|
||||||
|
$self->logger->debug("-> Trying to load $tmpl");
|
||||||
|
}
|
||||||
my $res = $self->SUPER::sendHtml( $req, $template, %args );
|
my $res = $self->SUPER::sendHtml( $req, $template, %args );
|
||||||
push @{ $res->[1] },
|
push @{ $res->[1] },
|
||||||
'X-XSS-Protection' => '1; mode=block',
|
'X-XSS-Protection' => '1; mode=block',
|
||||||
'X-Content-Type-Options' => 'nosniff',
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
'Cache-Control' => 'no-cache, no-store, must-revalidate',# HTTP 1.1
|
'Cache-Control' => 'no-cache, no-store, must-revalidate', # HTTP 1.1
|
||||||
'Pragma' => 'no-cache', # HTTP 1.0
|
'Pragma' => 'no-cache', # HTTP 1.0
|
||||||
'Expires' => '0'; # Proxies
|
'Expires' => '0'; # Proxies
|
||||||
|
|
||||||
# Set authorized URL for POST
|
# Set authorized URL for POST
|
||||||
my $csp = $self->csp . "form-action " . $self->conf->{cspFormAction};
|
my $csp = $self->csp . "form-action " . $self->conf->{cspFormAction};
|
||||||
|
@ -749,13 +747,14 @@ sub sendHtml {
|
||||||
if ( defined $url ) {
|
if ( defined $url ) {
|
||||||
$self->logger->debug("Required Params URL : $url");
|
$self->logger->debug("Required Params URL : $url");
|
||||||
if ( $url =~ s#(https?://[^/]+).*#$1# ) {
|
if ( $url =~ s#(https?://[^/]+).*#$1# ) {
|
||||||
$self->logger->debug("Set CSP form-action with Params URL : $url");
|
$self->logger->debug(
|
||||||
|
"Set CSP form-action with Params URL : $url");
|
||||||
$csp .= " $url";
|
$csp .= " $url";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( defined $req->{cspFormAction} ) {
|
if ( defined $req->{cspFormAction} ) {
|
||||||
$self->logger->debug(
|
$self->logger->debug( "Set CSP form-action with request URL: "
|
||||||
"Set CSP form-action with request URL: " . $req->{cspFormAction} );
|
. $req->{cspFormAction} );
|
||||||
$csp .= " " . $req->{cspFormAction};
|
$csp .= " " . $req->{cspFormAction};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,7 +780,7 @@ sub sendHtml {
|
||||||
my @url;
|
my @url;
|
||||||
if ( $req->info ) {
|
if ( $req->info ) {
|
||||||
@url = map { s#https?://([^/]+).*#$1#; $_ }
|
@url = map { s#https?://([^/]+).*#$1#; $_ }
|
||||||
( $req->info =~ /<iframe.*?src="(.*?)"/sg );
|
( $req->info =~ /<iframe.*?src="(.*?)"/sg );
|
||||||
}
|
}
|
||||||
if (@url) {
|
if (@url) {
|
||||||
$csp .= join( ' ', 'child-src', @url ) . ';';
|
$csp .= join( ' ', 'child-src', @url ) . ';';
|
||||||
|
@ -797,18 +796,17 @@ sub sendCss {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my $s = '/* LL::NG Portal CSS */';
|
my $s = '/* LL::NG Portal CSS */';
|
||||||
if ( $self->conf->{portalSkinBackground} ) {
|
if ( $self->conf->{portalSkinBackground} ) {
|
||||||
$s .=
|
$s
|
||||||
'html,body{background:url("'
|
.= 'html,body{background:url("'
|
||||||
. $self->staticPrefix
|
. $self->staticPrefix
|
||||||
. '/common/backgrounds/'
|
. '/common/backgrounds/'
|
||||||
. $self->conf->{portalSkinBackground}
|
. $self->conf->{portalSkinBackground}
|
||||||
. '") no-repeat center fixed;'
|
. '") no-repeat center fixed;'
|
||||||
. 'background-size:cover;}';
|
. 'background-size:cover;}';
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
[
|
[ 'Content-Type' => 'text/css',
|
||||||
'Content-Type' => 'text/css',
|
|
||||||
'Content-Length' => length($s),
|
'Content-Length' => length($s),
|
||||||
'Cache-Control' => 'public,max-age=3600',
|
'Cache-Control' => 'public,max-age=3600',
|
||||||
],
|
],
|
||||||
|
@ -832,16 +830,16 @@ sub lmError {
|
||||||
|
|
||||||
# Error code
|
# Error code
|
||||||
$templateParams{"ERROR$_"} = ( $httpError == $_ ? 1 : 0 )
|
$templateParams{"ERROR$_"} = ( $httpError == $_ ? 1 : 0 )
|
||||||
foreach ( 403, 404, 500, 502, 503 );
|
foreach ( 403, 404, 500, 502, 503 );
|
||||||
return $self->sendHtml( $req, 'error', params => \%templateParams );
|
return $self->sendHtml( $req, 'error', params => \%templateParams );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub rebuildCookies {
|
sub rebuildCookies {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my @tmp;
|
my @tmp;
|
||||||
for ( my $i = 0 ; $i < @{ $req->{respHeaders} } ; $i += 2 ) {
|
for ( my $i = 0; $i < @{ $req->{respHeaders} }; $i += 2 ) {
|
||||||
push @tmp, $req->respHeaders->[0], $req->respHeaders->[1]
|
push @tmp, $req->respHeaders->[0], $req->respHeaders->[1]
|
||||||
unless ( $req->respHeaders->[0] eq 'Set-Cookie' );
|
unless ( $req->respHeaders->[0] eq 'Set-Cookie' );
|
||||||
}
|
}
|
||||||
$req->{respHeaders} = \@tmp;
|
$req->{respHeaders} = \@tmp;
|
||||||
$self->buildCookie($req);
|
$self->buildCookie($req);
|
||||||
|
@ -856,8 +854,8 @@ sub tplParams {
|
||||||
$portalPath =~ s#[^/]+\.fcgi$##;
|
$portalPath =~ s#[^/]+\.fcgi$##;
|
||||||
|
|
||||||
for my $session_key ( keys %{ $req->{sessionInfo} } ) {
|
for my $session_key ( keys %{ $req->{sessionInfo} } ) {
|
||||||
$templateParams{ "session_" . $session_key } =
|
$templateParams{ "session_" . $session_key }
|
||||||
$req->{sessionInfo}->{$session_key};
|
= $req->{sessionInfo}->{$session_key};
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $env_key ( keys %{ $req->env } ) {
|
for my $env_key ( keys %{ $req->env } ) {
|
||||||
|
@ -878,7 +876,7 @@ sub tplParams {
|
||||||
sub registerLogin {
|
sub registerLogin {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
return
|
return
|
||||||
unless ( $self->conf->{loginHistoryEnabled}
|
unless ( $self->conf->{loginHistoryEnabled}
|
||||||
and defined $req->authResult );
|
and defined $req->authResult );
|
||||||
my $history = $req->sessionInfo->{_loginHistory} ||= {};
|
my $history = $req->sessionInfo->{_loginHistory} ||= {};
|
||||||
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login';
|
||||||
|
@ -888,17 +886,18 @@ sub registerLogin {
|
||||||
# Gather current login's parameters
|
# Gather current login's parameters
|
||||||
my $login = $self->_sumUpSession( $req->{sessionInfo}, 1 );
|
my $login = $self->_sumUpSession( $req->{sessionInfo}, 1 );
|
||||||
$login->{error} = $self->error( $req->authResult )
|
$login->{error} = $self->error( $req->authResult )
|
||||||
if ( $req->authResult );
|
if ( $req->authResult );
|
||||||
|
|
||||||
$self->logger->debug( " Current login -> " . $login->{error} )
|
$self->logger->debug( " Current login -> " . $login->{error} )
|
||||||
if ( $login->{error} );
|
if ( $login->{error} );
|
||||||
|
|
||||||
# Add current login into history
|
# Add current login into history
|
||||||
unshift @{ $history->{$type} }, $login;
|
unshift @{ $history->{$type} }, $login;
|
||||||
|
|
||||||
# Forget oldest logins
|
# Forget oldest logins
|
||||||
splice @{ $history->{$type} }, $self->conf->{ $type . "Number" }
|
splice @{ $history->{$type} }, $self->conf->{ $type . "Number" }
|
||||||
if ( scalar @{ $history->{$type} } > $self->conf->{ $type . "Number" } );
|
if (
|
||||||
|
scalar @{ $history->{$type} } > $self->conf->{ $type . "Number" } );
|
||||||
|
|
||||||
# Save into persistent session
|
# Save into persistent session
|
||||||
$self->updatePersistentSession( $req, { _loginHistory => $history, } );
|
$self->updatePersistentSession( $req, { _loginHistory => $history, } );
|
||||||
|
@ -911,12 +910,12 @@ sub registerLogin {
|
||||||
# @return hashref
|
# @return hashref
|
||||||
sub _sumUpSession {
|
sub _sumUpSession {
|
||||||
my ( $self, $session, $withoutUser ) = @_;
|
my ( $self, $session, $withoutUser ) = @_;
|
||||||
my $res =
|
my $res
|
||||||
$withoutUser
|
= $withoutUser
|
||||||
? {}
|
? {}
|
||||||
: { user => $session->{ $self->conf->{whatToTrace} } };
|
: { user => $session->{ $self->conf->{whatToTrace} } };
|
||||||
$res->{$_} = $session->{$_}
|
$res->{$_} = $session->{$_}
|
||||||
foreach ( "_utime", "ipAddr",
|
foreach ( "_utime", "ipAddr",
|
||||||
keys %{ $self->conf->{sessionDataToRemember} } );
|
keys %{ $self->conf->{sessionDataToRemember} } );
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -925,12 +924,12 @@ sub _sumUpSession {
|
||||||
sub loadTemplate {
|
sub loadTemplate {
|
||||||
my ( $self, $name, %prm ) = @_;
|
my ( $self, $name, %prm ) = @_;
|
||||||
$name .= '.tpl';
|
$name .= '.tpl';
|
||||||
my $file =
|
my $file
|
||||||
$self->conf->{templateDir} . '/'
|
= $self->conf->{templateDir} . '/'
|
||||||
. $self->conf->{portalSkin} . '/'
|
. $self->conf->{portalSkin} . '/'
|
||||||
. $name;
|
. $name;
|
||||||
$file = $self->conf->{templateDir} . '/common/' . $name
|
$file = $self->conf->{templateDir} . '/common/' . $name
|
||||||
unless ( -e $file );
|
unless ( -e $file );
|
||||||
unless ( -e $file ) {
|
unless ( -e $file ) {
|
||||||
die "Unable to find $name in $self->conf->{templateDir}";
|
die "Unable to find $name in $self->conf->{templateDir}";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user