Commit f5971ad9 authored by Xavier Guimard's avatar Xavier Guimard

Set configuration checkTime (#1454)

parent a725a8f2
......@@ -24,6 +24,7 @@ sub defaultValues {
'captcha_size' => 6,
'casAccessControlPolicy' => 'none',
'casAuthnLevel' => 1,
'checkTime' => 600,
'checkXSS' => 1,
'confirmFormMethod' => 'post',
'cookieName' => 'lemonldap',
......
......@@ -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 );
}
......
......@@ -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;
}
......
......@@ -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'
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment