Set configuration checkTime (#1454)

This commit is contained in:
Xavier Guimard 2018-06-15 19:00:14 +02:00
parent a725a8f28f
commit f5971ad98d
5 changed files with 21 additions and 4 deletions

View File

@ -24,6 +24,7 @@ sub defaultValues {
'captcha_size' => 6,
'casAccessControlPolicy' => 'none',
'casAuthnLevel' => 1,
'checkTime' => 600,
'checkXSS' => 1,
'confirmFormMethod' => 'post',
'cookieName' => 'lemonldap',

View File

@ -19,8 +19,12 @@ sub grant {
my ( $class, $req, $session, $uri, $cond, $vhost ) = @_;
$vhost ||= $class->resolveAlias($req);
$class->tsv->{lastVhostUpdate} //= {};
unless ( $class->tsv->{defaultCondition}->{$vhost}
and ( time() - $class->tsv->{lastVhostUpdate}->{$vhost} < 600 ) )
unless (
$class->tsv->{defaultCondition}->{$vhost}
and (
time() - $class->tsv->{lastVhostUpdate}->{$vhost} <
$class->tsv->{checkTime} )
)
{
$class->loadVhostConfig( $req, $vhost );
}

View File

@ -36,6 +36,7 @@ sub checkConf {
$class->logger->debug("Check configuration for $class");
my $prm = { local => !$force, localPrm => $class->localConfig };
my $conf = $class->confAcc->getConf($prm);
chomp $Lemonldap::NG::Common::Conf::msg;
unless ( ref($conf) ) {
$class->logger->error(
@ -57,7 +58,6 @@ sub checkConf {
}
if ( $force or !$class->cfgNum or $class->cfgNum != $conf->{cfgNum} ) {
$class->logger->debug("Get configuration $conf->{cfgNum}");
$class->lastCheck( time() );
unless ( $class->cfgNum( $conf->{cfgNum} ) ) {
$class->logger->error('No configuration available');
return 0;
@ -76,6 +76,8 @@ sub checkConf {
}
}
}
$class->tsv->{checkTime} = $conf->{checkTime} if ( $conf->{checkTime} );
$class->lastCheck( time() );
$class->logger->debug("$class: configuration is up to date");
return 1;
}

View File

@ -759,6 +759,10 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
'checkStateSecret' => {
'type' => 'text'
},
'checkTime' => {
'default' => 600,
'type' => 'int'
},
'checkXSS' => {
'default' => 1,
'type' => 'bool'

View File

@ -215,6 +215,12 @@ sub attributes {
return {
# Other
checkTime => {
type => 'int',
documentation =>
'Timeout to check new configuration in local cache',
default => 600,
},
configStorage => {
type => 'text',
documentation => 'Configuration storage',
@ -1441,7 +1447,7 @@ sub attributes {
grep { $_ =~ /Undefined subroutine/ ? () : $_ }
split( /\n/, $@ ) );
return $err ? ( 1, "__badExpression__: $err" ) : (1);
}
}
},
documentation => 'Virtualhost headers',
flags => 'h',