diff --git a/lemonldap-ng-handler/example/scripts/purgeLocalCache b/lemonldap-ng-handler/example/scripts/purgeLocalCache index 4e789ff59..37466142d 100755 --- a/lemonldap-ng-handler/example/scripts/purgeLocalCache +++ b/lemonldap-ng-handler/example/scripts/purgeLocalCache @@ -1,6 +1,6 @@ #!/usr/bin/perl #============================================================================= -# Cleaner for LemonLDAP::NG: purge local handler cache +# Cleaner for LemonLDAP::NG: purge local handler cache and session cache # # This module is written to be used by cron to clean cache objects used # by Handler. @@ -23,10 +23,19 @@ my $conf = $lmconf->getLocalConf(HANDLERSECTION) or die "Unable to get local configuration ($!)"; print "Configuration loaded\n" if $debug; + +# Handler cache exit 0 unless ( $conf->{localStorage} ); eval "require $conf->{localStorage}"; $conf->{localStorageOptions}->{default_expires_in} ||= 600; my $c = $conf->{localStorage}->new( $conf->{localStorageOptions} ); $c->purge(); +# Session cache +exit 0 unless ( $conf->{localSessionStorage} ); +eval "require $conf->{localSessionStorage}"; +$conf->{localSessionStorageOptions}->{default_expires_in} ||= 600; +my $s = $conf->{localSessionStorage}->new( $conf->{localSessionStorageOptions} ); +$s->purge(); + exit 0; diff --git a/lemonldap-ng-portal/example/scripts/purgeCentralCache b/lemonldap-ng-portal/example/scripts/purgeCentralCache index ed629f6bc..42ad251cd 100755 --- a/lemonldap-ng-portal/example/scripts/purgeCentralCache +++ b/lemonldap-ng-portal/example/scripts/purgeCentralCache @@ -11,6 +11,7 @@ use Lemonldap::NG::Common::Conf; use Lemonldap::NG::Common::Conf::Constants; use Lemonldap::NG::Common::Apache::Session; +use Lemonldap::NG::Common::Session; use strict; use Getopt::Std; @@ -44,9 +45,6 @@ print "Configuration loaded\n" if $debug; #============================================================================= # Timeout #============================================================================= -$conf->{timeout} ||= 7200; -$conf->{timeoutActivity} ||= 0; - print "Timeout value: " . $conf->{timeout} . "\n" if $debug; #============================================================================= @@ -87,6 +85,23 @@ if ( defined $conf->{samlStorage} print "SAML backend $module will be used\n" if $debug; } +# CAS +if ( defined $conf->{casStorage} + or keys %{ $conf->{casStorageOptions} } ) +{ + + # Load module + $module = $conf->{casStorage} || $conf->{globalStorage}; + eval "use $module"; + die $@ if ($@); + $conf->{casStorageOptions}->{backend} = $module; + + # Add module in managed backends + push @backends, $conf->{casStorageOptions}; + + print "CAS backend $module will be used\n" if $debug; +} + #============================================================================= # Load and purge sessions #============================================================================= @@ -136,18 +151,25 @@ for my $options (@backends) { # Delete sessions my @errors; for my $id (@t) { - my %h; - eval { tie %h, "Lemonldap::NG::Common::Apache::Session", $id, $options }; - if ($@) { - print "Error while opening session $id: $@\n" if $debug; + + my $session = Lemonldap::NG::Common::Session->new( + storageModule => $options->{backend}, + storageModuleOptions => $options, + cacheModule => $conf->{localSessionStorage}, + cacheModuleOptions => $conf->{localSessionStorageOptions}, + id => $id, + ); + + unless ( $session->data ) { + print "Error while opening session $id\n" if $debug; print STDERR "Error on session $id\n"; $nb_error++; push @errors, $id; next; } - eval { tied(%h)->delete; }; - if ($@) { - print "Error while deleting session $id: $@\n" if $debug; + + unless ( $session->remove ) { + print "Error while deleting session $id\n" if $debug; print STDERR "Error on session $id\n"; $nb_error++; push @errors, $id;