Fix bug with SAML data purge + simplify purgeCentralCache (Lemonldap-518)

This commit is contained in:
François-Xavier Deltombe 2012-09-03 18:56:39 +00:00
parent 2720d0538f
commit 2d9f9e088e

View File

@ -46,38 +46,33 @@ my @backends;
my $module;
# Sessions
if ( defined $conf->{globalStorage}
and $conf->{globalStorage} ne "Apache::Session::Memcached" )
{
if ( defined $conf->{globalStorage} ) {
# Load module
$module = $conf->{globalStorage};
eval "use $module";
die $@ if ($@);
$conf->{globalStorageOptions}->{backend} = $module;
$module = 'Lemonldap::NG::Common::Apache::Session';
# Add module in managed backends
push @backends, [ $module, $conf->{globalStorageOptions} ];
push @backends, $conf->{globalStorageOptions};
print "Session backend $module will be used\n" if $debug;
}
# SAML
if ( defined $conf->{samlStorage}
and $conf->{samlStorage} ne $conf->{globalStorage}
and $conf->{samlStorage} ne "Apache::Session::Memcached" )
if ( defined $conf->{samlStorage}
or keys %{ $conf->{samlStorageOptions} } )
{
# Load module
$module = $conf->{samlStorage};
$module = $conf->{samlStorage} || $conf->{globalStorage};
eval "use $module";
die $@ if ($@);
$conf->{samlStorageOptions}->{backend} = $module;
$module = 'Lemonldap::NG::Common::Apache::Session';
# Add module in managed backends
push @backends, [ $module, $conf->{samlStorageOptions} ];
push @backends, $conf->{samlStorageOptions};
print "SAML backend $module will be used\n" if $debug;
}
@ -85,13 +80,13 @@ if ( defined $conf->{samlStorage}
#=============================================================================
# Load and purge sessions
#=============================================================================
for my $backend (@backends) {
for my $options (@backends) {
my ( $storage, $options ) = splice @$backend;
next if ( $options->{backend} eq "Apache::Session::Memcached" );
my @t;
# Get all expired sessions
$storage->get_key_from_all_sessions(
Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions(
$options,
sub {
my $entry = shift;
@ -122,7 +117,7 @@ for my $backend (@backends) {
# Delete sessions
for my $id (@t) {
my %h;
eval { tie %h, $storage, $id, $options };
eval { tie %h, "Lemonldap::NG::Common::Apache::Session", $id, $options };
if ($@) {
print "Error while opening session $id: $@\n" if $debug;
next;