This commit is contained in:
Xavier Guimard 2016-08-02 13:52:29 +00:00
parent 469622fe97
commit 21d3efcc87
7 changed files with 23 additions and 16 deletions

View File

@ -127,7 +127,7 @@ sub run {
$class->set_user( $session->{ $class->tsv->{whatToTrace} } ); $class->set_user( $session->{ $class->tsv->{whatToTrace} } );
# AUTHORIZATION # AUTHORIZATION
return $class->forbidden($session) return ( $class->forbidden($session), $session )
unless ( $class->grant( $session, $uri, $cond ) ); unless ( $class->grant( $session, $uri, $cond ) );
$class->updateStatus( 'OK', $session->{ $class->tsv->{whatToTrace} } ); $class->updateStatus( 'OK', $session->{ $class->tsv->{whatToTrace} } );
@ -155,7 +155,7 @@ sub run {
$class->postOutputFilter( $session, $uri ); $class->postOutputFilter( $session, $uri );
$class->postInputFilter( $session, $uri ); $class->postInputFilter( $session, $uri );
return $class->OK; return ( $class->OK, $session );
} }
elsif ( $protection == $class->UNPROTECT ) { elsif ( $protection == $class->UNPROTECT ) {

View File

@ -95,9 +95,9 @@ sub status {
# response is 200. # response is 200.
sub _authAndTrace { sub _authAndTrace {
my ( $self, $req, $noCall ) = @_; my ( $self, $req, $noCall ) = @_;
my $res = $self->api->run( $req, $self->{rule} ); my ( $res, $session ) = $self->api->run( $req, $self->{rule} );
$self->portal( $self->api->tsv->{portal}->() ); $self->portal( $self->api->tsv->{portal}->() );
$req->userData( $self->api->datas ) if ( $self->api->datas ); $req->userData($session) if ($session);
if ( $res < 300 ) { if ( $res < 300 ) {
if ($noCall) { if ($noCall) {

View File

@ -368,6 +368,7 @@ sub buildHiddenForm {
# Return skin name # Return skin name
# @return skin name # @return skin name
# TODO: create property for skinRule
sub getSkin { sub getSkin {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;

View File

@ -224,9 +224,8 @@ sub reloadConf {
if ( $self->conf->{$type} ) { if ( $self->conf->{$type} ) {
for my $name ( sort keys %{ $self->conf->{$type} } ) { for my $name ( sort keys %{ $self->conf->{$type} } ) {
my $sub = my $sub =
HANDLER->tsv->{jail}->jail_reval( "sub{return(" HANDLER->buildSub(
. HANDLER->substitute( $self->conf->{$type}->{$name} ) HANDLER->substitute( $self->conf->{$type}->{$name} ) );
. ")}" );
if ($sub) { if ($sub) {
$self->{"_$type"}->{$name} = $sub; $self->{"_$type"}->{$name} = $sub;
} }
@ -241,8 +240,7 @@ sub reloadConf {
} }
} }
$self->{_jsRedirect} = $self->{_jsRedirect} =
HANDLER->tsv->{jail}->jail_reval( HANDLER->buildSub( HANDLER->substitute( $self->conf->{jsRedirect} ) )
"sub{return " . HANDLER->substitute( $self->conf->{jsRedirect} ) . "}" )
or $self->lmLog( or $self->lmLog(
'jsRedirect returns an error: ' . HANDLER->tsv->{jail}->error, 'jsRedirect returns an error: ' . HANDLER->tsv->{jail}->error,
'error' ); 'error' );

View File

@ -21,7 +21,7 @@ has menuModules => (
$_[0] $_[0]
->p->lmLog( "Evaluate condition $cond for module $_", 'debug' ); ->p->lmLog( "Evaluate condition $cond for module $_", 'debug' );
my $tmp = my $tmp =
$_[0]->{p}->HANDLER->tsv->{jail}->jail_reval("sub{return $cond}"); $_[0]->{p}->HANDLER->buildSub($cond);
push @res, [ $_, $tmp ] if ($tmp); push @res, [ $_, $tmp ] if ($tmp);
} }
return \@res; return \@res;

View File

@ -46,7 +46,7 @@ sub restoreArgs {
sub importHandlerDatas { sub importHandlerDatas {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
$req->{sessionInfo} = HANDLER->datas; $req->{sessionInfo} = $req->userData;
$req->id( $req->sessionInfo->{_session_id} ); $req->id( $req->sessionInfo->{_session_id} );
$req->user( $req->sessionInfo->{ $self->conf->{whatToTrace} } ); $req->user( $req->sessionInfo->{ $self->conf->{whatToTrace} } );
PE_OK; PE_OK;
@ -279,7 +279,7 @@ sub setSessionInfo {
$req->{sessionInfo}->{_url} = $req->{urldc}; $req->{sessionInfo}->{_url} = $req->{urldc};
# Share sessionInfo with underlying handler (needed for safe jail) # Share sessionInfo with underlying handler (needed for safe jail)
HANDLER->datas( $req->{sessionInfo} ); $req->userData( $req->{sessionInfo} );
# Call UserDB setSessionInfo # Call UserDB setSessionInfo
return $self->_userDB->setSessionInfo($req); return $self->_userDB->setSessionInfo($req);
@ -290,7 +290,7 @@ sub setSessionInfo {
sub setMacros { sub setMacros {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
foreach ( sort keys %{ $self->_macros } ) { foreach ( sort keys %{ $self->_macros } ) {
$req->{sessionInfo}->{$_} = $self->_macros->{$_}->(); $req->{sessionInfo}->{$_} = $self->_macros->{$_}->( $req->sessionInfo );
} }
PE_OK; PE_OK;
} }
@ -329,7 +329,7 @@ sub setPersistentSessionInfo {
sub setLocalGroups { sub setLocalGroups {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
foreach ( sort keys %{ $self->_groups } ) { foreach ( sort keys %{ $self->_groups } ) {
if ( $self->_groups->{$_}->() ) { if ( $self->_groups->{$_}->( $req->sessionInfo ) ) {
$req->{sessionInfo}->{groups} .= $req->{sessionInfo}->{groups} .=
$self->conf->{multiValuesSeparator} . $_; $self->conf->{multiValuesSeparator} . $_;
$req->{sessionInfo}->{hGroups}->{$_}->{name} = $_; $req->{sessionInfo}->{hGroups}->{$_}->{name} = $_;

View File

@ -226,7 +226,7 @@ sub getNotifBack {
or return $self->sendError( $req, 'Unable to decrypt', 500 ); or return $self->sendError( $req, 'Unable to decrypt', 500 );
# Verify that session exists # Verify that session exists
$self->p->HANDLER->retrieveSession($id) $req->userData( $self->p->HANDLER->retrieveSession($id) )
or return $self->sendError( $req, 'Unknown session', 401 ); or return $self->sendError( $req, 'Unknown session', 401 );
# Restore datas # Restore datas
@ -283,6 +283,9 @@ sub getNotifBack {
# Current pending notification has not been found in # Current pending notification has not been found in
# request # request
$result = $fileResult = 0; $result = $fileResult = 0;
$self->lmLog(
'Current pending notification has not been found',
'debug' );
next; next;
} }
@ -308,17 +311,22 @@ sub getNotifBack {
# One pending notification has been found and not accepted, # One pending notification has been found and not accepted,
# restart process to display pending notifications # restart process to display pending notifications
# TODO: is it a good idea to launch all 'afterDatas' subs ? # TODO: is it a good idea to launch all 'afterDatas' subs ?
$self->lmLog(
'Pending notification has been found and not accepted',
'debug' );
return $self->p->do( $req, $self->p->afterDatas ); return $self->p->do( $req, $self->p->afterDatas );
} }
# All pending notifications has been accepted, restore cookies and # All pending notifications have been accepted, restore cookies and
# launch 'controlUrl' to restore "urldc" using do() # launch 'controlUrl' to restore "urldc" using do()
$self->lmLog( 'All pending notifications have been accepted', 'debug' );
$self->rebuildCookies($req); $self->rebuildCookies($req);
$self->p->do( $req, ['controlUrl'] ); $self->p->do( $req, ['controlUrl'] );
} }
else { else {
# No notifications checked here, this entry point must not be called. # No notifications checked here, this entry point must not be called.
# Redirecting to portal # Redirecting to portal
$self->lmLog( 'No notifications checked', 'debug' );
$req->mustRedirect(1); $req->mustRedirect(1);
$self->p->do( $req, [] ); $self->p->do( $req, [] );
} }