-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
diff --git a/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm b/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm | ||
index edf6a5f19..89c7571d2 100644 | ||
--- a/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm | ||
+++ b/usr/share/perl5/Lemonldap/NG/Manager/Sessions.pm | ||
@@ -40,6 +40,13 @@ sub init { | ||
['DELETE'] | ||
) | ||
|
||
+ # DELETE ALL SESSIONS FOR A USER | ||
+ ->addRoute( | ||
+ sessions => | ||
+ { glogout => { ':sessionType' => { ':sessionId' => 'userLogout' } } }, | ||
+ ['POST'] | ||
+ ) | ||
+ | ||
# DELETE OIDC CONSENT | ||
->addRoute( | ||
sessions => { | ||
@@ -60,6 +67,58 @@ sub init { | ||
return 1; | ||
} | ||
|
||
+# | ||
+# User logout | ||
+# | ||
+ | ||
+sub userLogout { | ||
+ my ( $self, $req ) = @_; | ||
+ | ||
+ my $mod = $self->getMod($req) | ||
+ or return $self->sendError( $req, undef, 400 ); | ||
+ my $id = $req->params('sessionId') | ||
+ or return $self->sendError( $req, 'sessionId is missing', 400 ); | ||
+ my $session = $self->getApacheSession( $mod, $id ); | ||
+ | ||
+ my $uidKey = Lemonldap::NG::Handler::Main->tsv->{whatToTrace}; | ||
+ my $uid = $session->data->{$uidKey}; | ||
+ | ||
+ my $count = 0; | ||
+ foreach my $storage (qw(oidcStorage sessionStorage)) { | ||
+ my $storageModule = | ||
+ Lemonldap::NG::Handler::Main->tsv->{"${storage}Module"}; | ||
+ if ( defined $storageModule ) { | ||
+ next if ( $storageModule eq "Apache::Session::Memcached" ); | ||
+ my $opts = Lemonldap::NG::Handler::Main->tsv->{"${storage}Options"}; | ||
+ $opts->{backend} = $storageModule; | ||
+ my $sessions = | ||
+ Lemonldap::NG::Common::Apache::Session->searchOn( $opts, $uidKey, | ||
+ $uid ); | ||
+ my @keys; | ||
+ if ( $sessions and %$sessions ) { | ||
+ @keys = keys %$sessions; | ||
+ foreach my $sid (@keys) { | ||
+ my $session = Lemonldap::NG::Common::Session->new( | ||
+ storageModule => $storageModule, | ||
+ storageModuleOptions => $opts, | ||
+ cacheModule => Lemonldap::NG::Handler::Main->tsv | ||
+ ->{sessionCacheModule}, | ||
+ cacheModuleOptions => Lemonldap::NG::Handler::Main->tsv | ||
+ ->{sessionCacheOptions}, | ||
+ id => $sid, | ||
+ ); | ||
+ if ( $session->data ) { | ||
+ $session->remove; | ||
+ $count++; | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ Lemonldap::NG::Handler::PSGI::Main->localUnlog( $req, $id ); | ||
+ return $self->sendJSONresponse( $req, { result => 1, count => $count } ); | ||
+} | ||
+ | ||
####################### | ||
# II. CONSENT METHODS # | ||
####################### |
Oops, something went wrong.