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