Bugzilla – Attachment 132231 Details for
Bug 29957
Cookies not removed after logout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29957: Clear cookies on logout
Bug-29957-Clear-cookies-on-logout.patch (text/plain), 5.04 KB, created by
Nick Clemens (kidclamp)
on 2022-03-25 12:21:42 UTC
(
hide
)
Description:
Bug 29957: Clear cookies on logout
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-03-25 12:21:42 UTC
Size:
5.04 KB
patch
obsolete
>From d233b6421a54333d47a0a42e51ee4750c9c0ddea Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 27 Jan 2022 12:33:57 +0100 >Subject: [PATCH] Bug 29957: Clear cookies on logout > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Amended: Reverted the change to $cookies to minimize changes. >Fixed Auth.t where checkauth is being mocked. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Auth.pm | 32 ++++++++++++++++++++------------ > t/db_dependent/Auth.t | 2 +- > 2 files changed, 21 insertions(+), 13 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index b4edd2d932..e2b1d47931 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -154,6 +154,7 @@ sub get_template_and_user { > > my $in = shift; > my ( $user, $cookie, $sessionID, $flags ); >+ $cookie = []; > > # Get shibboleth login attribute > my $shib = C4::Context->config('useshibboleth') && shib_ok(); >@@ -243,7 +244,7 @@ sub get_template_and_user { > if ($kick_out) { > $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac', > $in->{query} ); >- $cookie = $in->{query}->cookie( >+ push @$cookie, $in->{query}->cookie( > -name => 'CGISESSID', > -value => '', > -expires => '', >@@ -656,11 +657,7 @@ sub get_template_and_user { > # what to do > my $language = C4::Languages::getlanguage( $in->{'query'} ); > my $languagecookie = C4::Templates::getlanguagecookie( $in->{'query'}, $language ); >- if ( ref $cookie eq 'ARRAY' ) { >- push @{$cookie}, $languagecookie; >- } else { >- $cookie = [ $cookie, $languagecookie ]; >- } >+ push @{$cookie}, $languagecookie; > } > > return ( $template, $borrowernumber, $cookie, $flags ); >@@ -810,6 +807,15 @@ sub _timeout_syspref { > return $timeout; > } > >+sub clear_all_cookies { >+ my ( $query ) = shift; >+ my @cookies; >+ for my $cookie_name ( $query->cookie ) { >+ push @cookies, $query->cookie( -name => $cookie_name, -value => '', -expires => '', -HttpOnly => 1 ); >+ } >+ return \@cookies; >+} >+ > sub checkauth { > my $query = shift; > >@@ -846,6 +852,7 @@ sub checkauth { > my $loggedin = 0; > my %info; > my ( $userid, $cookie, $sessionID, $flags ); >+ $cookie = []; > my $logout = $query->param('logout.x'); > > my $anon_search_history; >@@ -869,7 +876,7 @@ sub checkauth { > if ( !$shib and defined( $ENV{'REMOTE_USER'} ) and $ENV{'REMOTE_USER'} ne '' and $userid = $ENV{'REMOTE_USER'} ) { > > # Using Basic Authentication, no cookies required >- $cookie = $query->cookie( >+ push @$cookie, $query->cookie( > -name => 'CGISESSID', > -value => '', > -expires => '', >@@ -914,6 +921,7 @@ sub checkauth { > my $shibSuccess = C4::Context->userenv->{'shibboleth'}; > $session->delete(); > $session->flush; >+ $cookie = clear_all_cookies($query); > C4::Context::_unset_userenv($sessionID); > $sessionID = undef; > >@@ -927,7 +935,7 @@ sub checkauth { > } > } else { > >- $cookie = $query->cookie( >+ push @$cookie, $query->cookie( > -name => 'CGISESSID', > -value => $session->id, > -HttpOnly => 1, >@@ -971,7 +979,7 @@ sub checkauth { > > $sessionID = $session->id; > C4::Context->_new_userenv($sessionID); >- $cookie = $query->cookie( >+ push @$cookie, $query->cookie( > -name => 'CGISESSID', > -value => $sessionID, > -HttpOnly => 1, >@@ -1171,7 +1179,7 @@ sub checkauth { > $domain =~ s|\.\*||g; > if ( $ip !~ /^$domain/ ) { > $loggedin = 0; >- $cookie = $query->cookie( >+ push @$cookie, $query->cookie( > -name => 'CGISESSID', > -value => '', > -HttpOnly => 1, >@@ -1259,8 +1267,8 @@ sub checkauth { > if ( $loggedin || $authnotrequired ) > { > # successful login >- unless ($cookie) { >- $cookie = $query->cookie( >+ unless (@$cookie) { >+ push @$cookie, $query->cookie( > -name => 'CGISESSID', > -value => '', > -HttpOnly => 1, >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 8c7f82c666..a6fbc448e3 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -229,7 +229,7 @@ subtest 'get_template_and_user' => sub { # Tests for the language URL paramete > -HttpOnly => 1 > ); > >- return ( $userid, $session_cookie, $sessionID, $flags ); >+ return ( $userid, [ $session_cookie ], $sessionID, $flags ); > } > > # Mock checkauth, build the scenario >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29957
:
129871
|
129872
|
130005
|
130006
|
131428
|
131750
|
131751
|
131752
|
131807
|
131808
|
131809
|
131810
|
131824
|
131825
|
131826
|
131827
|
131828
|
131840
|
131841
|
131842
|
131843
|
131856
|
132045
|
132046
|
132047
|
132105
|
132106
|
132107
|
132108
|
132109
|
132110
|
132111
|
132115
|
132210
|
132211
|
132231
|
132232
|
132233
|
132234
|
132235
|
132236
|
132237
|
132238
|
132239
|
132288
|
132289
|
132290
|
132291
|
132292
|
132293
|
132294
|
132295
|
132296