LL::NG::Handler: move $ntsv vars (except $ntsv->{datasUpdate})
into $tsv, since they can be thread shared (#630)
This commit is contained in:
parent
e9dd825518
commit
dcabb537d6
|
@ -217,7 +217,7 @@ package Lemonldap::NG::Handler::_CGI;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
#use Lemonldap::NG::Handler::SharedConf qw(:locationRules :localStorage :traces);
|
#use Lemonldap::NG::Handler::SharedConf qw(:locationRules :localStorage :traces);
|
||||||
use Lemonldap::NG::Handler::SharedConf qw(:tsv :ntsv :jailSharedVars);
|
use Lemonldap::NG::Handler::SharedConf qw(:tsv :jailSharedVars);
|
||||||
use Lemonldap::NG::Handler::Main::Jail;
|
use Lemonldap::NG::Handler::Main::Jail;
|
||||||
|
|
||||||
use base qw(Lemonldap::NG::Handler::SharedConf);
|
use base qw(Lemonldap::NG::Handler::SharedConf);
|
||||||
|
@ -229,13 +229,13 @@ sub safe_reval {
|
||||||
my $rule = shift;
|
my $rule = shift;
|
||||||
|
|
||||||
my $jail = Lemonldap::NG::Handler::Main::Jail->new(
|
my $jail = Lemonldap::NG::Handler::Main::Jail->new(
|
||||||
'safe' => $ntsv->{safe},
|
'safe' => $tsv->{safe},
|
||||||
'useSafeJail' => $tsv->{useSafeJail},
|
'useSafeJail' => $tsv->{useSafeJail},
|
||||||
'customFunctions' => $tsv->{customFunctions}
|
'customFunctions' => $tsv->{customFunctions}
|
||||||
);
|
);
|
||||||
$ntsv->{safe} = $jail->build_safe();
|
$tsv->{safe} = $jail->build_safe();
|
||||||
|
|
||||||
return $ntsv->{safe}->reval($rule);
|
return $tsv->{safe}->reval($rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
## @method boolean childInit()
|
## @method boolean childInit()
|
||||||
|
|
|
@ -39,33 +39,28 @@ our @EXPORT_OK;
|
||||||
|
|
||||||
our @EXPORT;
|
our @EXPORT;
|
||||||
|
|
||||||
# my @tSharedVar = qw(
|
# my @threadSharedVar = qw(
|
||||||
# cookieName customFunctions defaultCondition
|
# cda childInitDone cipher
|
||||||
# defaultProtection forgeHeaders globalStorage
|
# cookieExpiration cookieName customFunctions
|
||||||
# globalStorageOptions headerList https
|
# defaultCondition defaultProtection forgeHeaders
|
||||||
# key localStorage localStorageOptions
|
# globalStorage globalStorageOptions headerList
|
||||||
# locationCondition locationConditionText locationCount
|
# httpOnly https key
|
||||||
# locationProtection locationRegexp maintenance
|
# localStorage localStorageOptions locationCondition
|
||||||
# port refLocalStorage securedCookie
|
# locationConditionText locationCount locationProtection
|
||||||
# statusOut statusPipe timeoutActivity
|
# locationRegexp maintenance port
|
||||||
# useRedirectOnError useRedirectOnForbidden useSafeJail
|
# refLocalStorage safe securedCookie
|
||||||
# whatToTrace
|
# statusOut statusPipe timeoutActivity
|
||||||
|
# transform useRedirectOnError useRedirectOnForbidden
|
||||||
|
# useSafeJail whatToTrace
|
||||||
# );
|
# );
|
||||||
#
|
#
|
||||||
# my @nontSharedVar = qw(
|
# non thread shared vars
|
||||||
# safe
|
|
||||||
# cipher datasUpdate transform
|
|
||||||
# cda childInitDone httpOnly
|
|
||||||
# cookieExpiration
|
|
||||||
# );
|
|
||||||
#
|
|
||||||
# non threaded shared vars non being part of $ntsv hashref
|
|
||||||
# (because of share_from in Jail.pm):
|
|
||||||
# $apacheRequest
|
# $apacheRequest
|
||||||
# $datas
|
# $datas
|
||||||
|
# $datasUpdate
|
||||||
|
|
||||||
# Shared variables
|
# Shared variables
|
||||||
our ( $apacheRequest, $datas, $tsv, $ntsv, );
|
our ( $apacheRequest, $datas, $datasUpdate, $tsv );
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# COMPATIBILITY WITH APACHE AND APACHE 2 #
|
# COMPATIBILITY WITH APACHE AND APACHE 2 #
|
||||||
|
@ -79,7 +74,6 @@ BEGIN {
|
||||||
locationRules => [qw( )],
|
locationRules => [qw( )],
|
||||||
jailSharedVars => [qw( $apacheRequest $datas )],
|
jailSharedVars => [qw( $apacheRequest $datas )],
|
||||||
tsv => [qw( $tsv )],
|
tsv => [qw( $tsv )],
|
||||||
ntsv => [qw( $ntsv )],
|
|
||||||
import => [qw( import @EXPORT_OK @EXPORT %EXPORT_TAGS )],
|
import => [qw( import @EXPORT_OK @EXPORT %EXPORT_TAGS )],
|
||||||
headers => [
|
headers => [
|
||||||
qw(
|
qw(
|
||||||
|
@ -336,7 +330,7 @@ sub fetchId {
|
||||||
? ( $t =~ /$tsv->{cookieName}http=([^,; ]+)/o ? $1 : 0 )
|
? ( $t =~ /$tsv->{cookieName}http=([^,; ]+)/o ? $1 : 0 )
|
||||||
: ( $t =~ /$tsv->{cookieName}=([^,; ]+)/o ? $1 : 0 );
|
: ( $t =~ /$tsv->{cookieName}=([^,; ]+)/o ? $1 : 0 );
|
||||||
|
|
||||||
$value = $ntsv->{cipher}->decryptHex( $value, "http" )
|
$value = $tsv->{cipher}->decryptHex( $value, "http" )
|
||||||
if ( $value && $lookForHttpCookie && $tsv->{securedCookie} == 3 );
|
if ( $value && $lookForHttpCookie && $tsv->{securedCookie} == 3 );
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +346,7 @@ sub retrieveSession {
|
||||||
return 1
|
return 1
|
||||||
if ( defined $datas->{_session_id}
|
if ( defined $datas->{_session_id}
|
||||||
and $id eq $datas->{_session_id}
|
and $id eq $datas->{_session_id}
|
||||||
and ( time() - $ntsv->{datasUpdate} < 60 ) );
|
and ( time() - $datasUpdate < 60 ) );
|
||||||
|
|
||||||
# 2. Get the session from cache or backend
|
# 2. Get the session from cache or backend
|
||||||
my $apacheSession = Lemonldap::NG::Common::Session->new(
|
my $apacheSession = Lemonldap::NG::Common::Session->new(
|
||||||
|
@ -390,7 +384,7 @@ sub retrieveSession {
|
||||||
$datas->{$_} = $apacheSession->data->{$_}
|
$datas->{$_} = $apacheSession->data->{$_}
|
||||||
foreach ( keys %{ $apacheSession->data } );
|
foreach ( keys %{ $apacheSession->data } );
|
||||||
|
|
||||||
$ntsv->{datasUpdate} = time();
|
$datasUpdate = time();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +436,7 @@ sub run ($$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cross domain authentication
|
# Cross domain authentication
|
||||||
if ( $ntsv->{cda}
|
if ( $tsv->{cda}
|
||||||
and $args =~ s/[\?&]?($tsv->{cookieName}(http)?=\w+)$//oi )
|
and $args =~ s/[\?&]?($tsv->{cookieName}(http)?=\w+)$//oi )
|
||||||
{
|
{
|
||||||
my $str = $1;
|
my $str = $1;
|
||||||
|
@ -457,10 +451,10 @@ sub run ($$) {
|
||||||
$apacheRequest,
|
$apacheRequest,
|
||||||
'Set-Cookie' => "$str; path=/"
|
'Set-Cookie' => "$str; path=/"
|
||||||
. ( $redirectHttps ? "; secure" : "" )
|
. ( $redirectHttps ? "; secure" : "" )
|
||||||
. ( $ntsv->{httpOnly} ? "; HttpOnly" : "" )
|
. ( $tsv->{httpOnly} ? "; HttpOnly" : "" )
|
||||||
. (
|
. (
|
||||||
$ntsv->{cookieExpiration}
|
$tsv->{cookieExpiration}
|
||||||
? "; expires=" . expires( $ntsv->{cookieExpiration}, 'cookie' )
|
? "; expires=" . expires( $tsv->{cookieExpiration}, 'cookie' )
|
||||||
: ""
|
: ""
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -632,9 +626,8 @@ sub localInit($$) {
|
||||||
);
|
);
|
||||||
(
|
(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( localStorage refLocalStorage localStorageOptions statusPipe statusOut )
|
qw( localStorage refLocalStorage localStorageOptions statusPipe statusOut childInitDone )
|
||||||
},
|
}
|
||||||
$ntsv->{childInitDone}
|
|
||||||
) = $localinit->localInit($args);
|
) = $localinit->localInit($args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -658,46 +651,40 @@ sub globalInit {
|
||||||
my $globalinit = Lemonldap::NG::Handler::Initialization::GlobalInit->new(
|
my $globalinit = Lemonldap::NG::Handler::Initialization::GlobalInit->new(
|
||||||
customFunctions => $tsv->{customFunctions},
|
customFunctions => $tsv->{customFunctions},
|
||||||
useSafeJail => $tsv->{useSafeJail},
|
useSafeJail => $tsv->{useSafeJail},
|
||||||
safe => $ntsv->{safe},
|
safe => $tsv->{safe},
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( cookieName securedCookie whatToTrace
|
qw( cookieName securedCookie whatToTrace
|
||||||
https port customFunctions
|
https port customFunctions
|
||||||
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
||||||
useSafeJail key maintenance )
|
useSafeJail key maintenance
|
||||||
},
|
cda httpOnly cookieExpiration
|
||||||
@$ntsv{
|
cipher )
|
||||||
qw( cda httpOnly cookieExpiration
|
|
||||||
cipher
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
= $globalinit->defaultValuesInit(
|
= $globalinit->defaultValuesInit(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( cookieName securedCookie whatToTrace
|
qw( cookieName securedCookie whatToTrace
|
||||||
https port customFunctions
|
https port customFunctions
|
||||||
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
||||||
useSafeJail key maintenance )
|
useSafeJail key maintenance
|
||||||
},
|
cda httpOnly cookieExpiration
|
||||||
@$ntsv{
|
|
||||||
qw( cda httpOnly cookieExpiration
|
|
||||||
cipher )
|
cipher )
|
||||||
},
|
},
|
||||||
@_
|
@_
|
||||||
);
|
);
|
||||||
|
|
||||||
( *portal, $ntsv->{safe} ) = $globalinit->portalInit( $class, @_ );
|
( *portal, $tsv->{safe} ) = $globalinit->portalInit( $class, @_ );
|
||||||
|
|
||||||
(
|
(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( locationCount defaultCondition
|
qw( locationCount defaultCondition
|
||||||
defaultProtection locationCondition
|
defaultProtection locationCondition
|
||||||
locationProtection locationRegexp
|
locationProtection locationRegexp
|
||||||
locationConditionText )
|
locationConditionText safe )
|
||||||
},
|
}
|
||||||
$ntsv->{safe}
|
|
||||||
)
|
)
|
||||||
= $globalinit->locationRulesInit(
|
= $globalinit->locationRulesInit(
|
||||||
$class,
|
$class,
|
||||||
|
@ -723,7 +710,7 @@ sub globalInit {
|
||||||
$tsv->{forgeHeaders} =
|
$tsv->{forgeHeaders} =
|
||||||
$globalinit->forgeHeadersInit( $tsv->{forgeHeaders}, @_ );
|
$globalinit->forgeHeadersInit( $tsv->{forgeHeaders}, @_ );
|
||||||
|
|
||||||
$ntsv->{transform} = $globalinit->postUrlInit( $ntsv->{transform}, @_ );
|
$tsv->{transform} = $globalinit->postUrlInit( $tsv->{transform}, @_ );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package Lemonldap::NG::Handler::Main::PostForm;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
# For importing MP function, $ntsv->{transform}, $apacheRequest,
|
# For importing MP function, $tsv->{transform}, $apacheRequest,
|
||||||
# $ntsv->{safe}, $tsv->{useSafeJail}, $tsv->{customFunctions}
|
# $tsv->{safe}, $tsv->{useSafeJail}, $tsv->{customFunctions}
|
||||||
use Lemonldap::NG::Handler::Main qw( :apache :ntsv :tsv $apacheRequest );
|
use Lemonldap::NG::Handler::Main qw( :apache :tsv $apacheRequest );
|
||||||
use Lemonldap::NG::Handler::Main::Logger;
|
use Lemonldap::NG::Handler::Main::Logger;
|
||||||
use Lemonldap::NG::Handler::Main::Jail;
|
use Lemonldap::NG::Handler::Main::Jail;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ sub transformUri {
|
||||||
my ( $class, $uri ) = splice @_;
|
my ( $class, $uri ) = splice @_;
|
||||||
my $vhost = $apacheRequest->hostname;
|
my $vhost = $apacheRequest->hostname;
|
||||||
|
|
||||||
if ( defined( $ntsv->{transform}->{$vhost}->{$uri} ) ) {
|
if ( defined( $tsv->{transform}->{$vhost}->{$uri} ) ) {
|
||||||
return &{ $ntsv->{transform}->{$vhost}->{$uri} };
|
return &{ $tsv->{transform}->{$vhost}->{$uri} };
|
||||||
}
|
}
|
||||||
|
|
||||||
OK;
|
OK;
|
||||||
|
@ -87,13 +87,13 @@ sub postFilter {
|
||||||
my $u = URI->new('http:');
|
my $u = URI->new('http:');
|
||||||
|
|
||||||
my $jail = Lemonldap::NG::Handler::Main::Jail->new(
|
my $jail = Lemonldap::NG::Handler::Main::Jail->new(
|
||||||
'safe' => $ntsv->{safe},
|
'safe' => $tsv->{safe},
|
||||||
'useSafeJail' => $tsv->{useSafeJail},
|
'useSafeJail' => $tsv->{useSafeJail},
|
||||||
'customFunctions' => $tsv->{customFunctions}
|
'customFunctions' => $tsv->{customFunctions}
|
||||||
);
|
);
|
||||||
$ntsv->{safe} = $jail->build_safe();
|
$tsv->{safe} = $jail->build_safe();
|
||||||
|
|
||||||
$u->query_form( { $ntsv->{safe}->reval($data) } );
|
$u->query_form( { $tsv->{safe}->reval($data) } );
|
||||||
my $s = $u->query();
|
my $s = $u->query();
|
||||||
|
|
||||||
# Eat all fake data sent by client
|
# Eat all fake data sent by client
|
||||||
|
|
|
@ -95,26 +95,21 @@ sub defaultValuesInit {
|
||||||
|
|
||||||
(
|
(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( cookieName securedCookie whatToTrace
|
qw( cookieName securedCookie whatToTrace
|
||||||
https port customFunctions
|
https port customFunctions
|
||||||
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
||||||
useSafeJail key maintenance )
|
useSafeJail key maintenance
|
||||||
},
|
cda httpOnly cookieExpiration
|
||||||
@$ntsv{
|
cipher )
|
||||||
qw( cda httpOnly cookieExpiration
|
|
||||||
cipher
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
= $globalinit->defaultValuesInit(
|
= $globalinit->defaultValuesInit(
|
||||||
@$tsv{
|
@$tsv{
|
||||||
qw( cookieName securedCookie whatToTrace
|
qw( cookieName securedCookie whatToTrace
|
||||||
https port customFunctions
|
https port customFunctions
|
||||||
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
timeoutActivity useRedirectOnError useRedirectOnForbidden
|
||||||
useSafeJail key maintenance )
|
useSafeJail key maintenance
|
||||||
},
|
cda httpOnly cookieExpiration
|
||||||
@$ntsv{
|
|
||||||
qw( cda httpOnly cookieExpiration
|
|
||||||
cipher )
|
cipher )
|
||||||
},
|
},
|
||||||
\%h
|
\%h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user