Koha/C4
Jonathan Druart 3dd1cdd74f Bug 36149: Unset userenv from middleware
The userenv (logged in user's info) are stored in
$C4::Context->context->{activeuser}, which persists in plack worker's
memory.
It's really bad in theory as we are not cleaning it before or after the
HTTP request, but only when set_userenv is called (what we are doing
commonly in C4::Auth::get_template_and_user).
If C4::Context->userenv is called before set_userenv we should get undef,
not the userenv from the previous request!
In practice this should not be a problem, but well... who really knows?

This patch suggests to have a middleware to deal with removing the
userenv at the beginning of each request (maybe it should be after, right? - FIXME).

To test:
1 - Edit /etc/koha/sites/kohadev/koha-conf.xml to set <plack_workers>1</plack_workers>
2 - Edit about.pl  and add a line after: CGI->new:
    warn Data::Dumper::Dumper( C4::Cointext->userenv() );
3 - tail -f /var/log/koha/kohadev/*.log
4 - View about.pl in staff interface, should get a "somethign's wrong" warning
5 - Reload, you get current user info
6 - Open an incognito tab, sign in as a different user and click some stuff
7 - Reload about.pl in other window
8 - You get the opac user info
9 - Apply patch
10 - Edit /etc/koha/sites/kohadev/plack.psgi and add the middleware after "RealIP":
     enable "+Koha::Middleware::UserEnv";
11 - Restart all
12 - Reload about.pl - you get a "Something's wrong" warning
13 - Click things in opac on incognito window
14 - Reload about.pl  - only "Something's wrong" - you no longer see any user info

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 576e7e09fdca703f76c0d10ae55eebf12ee1fdf4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2024-04-24 07:36:20 +02:00
..
AuthoritiesMarc
Barcodes
ClassSortRoutine
ClassSplitRoutine
Creators Bug 10762: (QA follow-up) Perltidy 2023-10-25 10:35:31 -03:00
External
Form
Heading
ILSDI Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron 2024-01-29 10:15:53 +01:00
Installer
Labels Bug 10762: (QA follow-up) Perltidy 2023-10-25 10:35:31 -03:00
Linker
Members
OAI
Output
Patroncards
Reports
Search
Serials
SIP Bug 35944: (QA follow-up) Tidy 2024-04-17 11:24:53 +02:00
Utils/DataTables Bug 34913: Fix perlcritic for VirtualShelves.pm 2024-01-31 13:49:30 +01:00
Accounts.pm
Acquisition.pm
Auth.pm Bug 36056: Clarify subpermissions AND behavior 2024-03-11 11:23:45 +01:00
Auth_cas_servers.yaml.sample
Auth_with_cas.pm Bug 34893: (QA follow-up) Tidy code for qa script 2024-01-29 10:15:53 +01:00
Auth_with_ldap.pm Bug 29930: Cardnumber incorrectly set to userid on LDAP auth if cardnumber not mapped 2024-01-31 13:56:32 +01:00
Auth_with_shibboleth.pm Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron 2024-01-29 10:15:53 +01:00
AuthoritiesMarc.pm Bug 29522: [alternate] Skip relinking bibliographic records when merging authorities 2024-03-18 10:29:21 +01:00
Barcodes.pm
Biblio.pm Bug 35490: Remove GetMarcItem from C4::Biblio module 2024-02-13 11:22:09 +01:00
Breeding.pm
Budgets.pm
Calendar.pm
Charset.pm
Circulation.pm Bug 36331: (follow-up) Ignore non_priority holds when checking renewability 2024-04-17 13:58:15 +02:00
ClassSortRoutine.pm
ClassSource.pm
ClassSplitRoutine.pm
Context.pm Bug 36149: Unset userenv from middleware 2024-04-24 07:36:20 +02:00
Contract.pm
CourseReserves.pm
Creators.pm
Heading.pm
HoldsQueue.pm Bug 34678: Allow new entries to overwrite hold_fill_targets 2023-10-27 16:44:24 -03:00
HTML5Media.pm
ImportBatch.pm Bug 35438: Remove skip_intermediate_commit parameter 2024-01-17 10:30:13 +01:00
ImportExportFramework.pm
InstallAuth.pm
Installer.pm
ItemCirculationAlertPreference.pm
Items.pm Bug 32029: Automatic item modifications by age add biblio table 2024-03-11 11:16:47 +01:00
Koha.pm Bug 35833: Fix warnings from C4/Koha 2024-02-01 15:06:57 +01:00
Labels.pm
Languages.pm
Letters.pm Bug 36244: Do template toolkit processing first 2024-03-27 07:54:16 +01:00
Linker.pm
Log.pm
MarcModificationTemplates.pm
Matcher.pm
Members.pm Bug 26170: Add protected status for patrons 2023-11-01 17:23:06 -03:00
Message.pm
Output.pm
Overdues.pm
Patroncards.pm
Record.pm Bug 35588: Scope authorised value desc lookup according to field/subfield 2024-01-03 17:05:14 +01:00
Reports.pm
Reserves.pm Bug 35491: Add logging to RevertWaitingStatus 2024-01-03 16:08:46 +01:00
Ris.pm
RotatingCollections.pm
Scheduler.pm
Scrubber.pm Bug 36328: (QA follow-up) Expand tests and reorder elements to clarify differences 2024-04-24 07:36:20 +02:00
Search.pm Bug 35833: Silence few warnings from searching 2024-02-01 15:06:57 +01:00
Serials.pm Bug 31846: (QA follow-up) Tidy code to make qa script happy 2023-10-25 10:35:28 -03:00
Service.pm
ShelfBrowser.pm
SMS.pm
SocialData.pm
Stats.pm Bug 33608: (QA follow-up) Remove ->insert method 2023-10-25 11:07:59 -03:00
Suggestions.pm
Tags.pm
Templates.pm Bug 35070: Tidy 2024-01-08 15:18:37 +01:00
TmplToken.pm
TmplTokenType.pm
TTParser.pm
UsageStats.pm
XISBN.pm
XSLT.pm Bug 33217: Tidy 2023-11-08 17:52:42 -03:00