Koha/debian/templates
Jonathan Druart df23f6c345
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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2024-05-14 15:04:36 -03:00
..
apache-shared-disable.conf
apache-shared-intranet-plack.conf Bug 33963: Remove C4::BackgroundJob 2023-06-15 08:48:12 -03:00
apache-shared-intranet.conf Bug 35919: Add record sources admin page 2024-04-26 17:06:04 +02:00
apache-shared-opac-plack.conf Bug 35812: Fix search URL aliases in Plack Apache config 2024-05-10 14:11:55 +02:00
apache-shared-opac.conf Bug 25548: Remove Apache rewrite directives that trigger redirects 2020-11-20 14:23:52 +01:00
apache-shared.conf Bug 36531: Serve text/javascript compressed, like application/javascript is 2024-04-08 15:41:12 +02:00
apache-site-https.conf.in Bug 34193: SSLProtocol enable in use versions and disable deprecated versions 2023-08-18 10:29:21 +03:00
apache-site.conf.in Bug 18670: Remove RewriteLog and RewriteLogLevel from sample config files 2020-05-05 10:59:03 +01:00
koha-common.conf Bug 10942: (follow-up) debconfing the update option 2014-04-24 12:49:32 +00:00
koha-conf-site.xml.in Bug 30897: (QA follow-up) Enable graceful restart by default 2024-04-11 16:53:43 +02:00
koha-core.conf Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-sites.conf Bug 18984: Remove NORMARC support 2021-10-07 15:36:40 +02:00
koha-worker@.service Bug 32992: Move background_jobs_worker to misc/workers 2023-02-24 17:52:19 -03:00
log4perl-site.conf.in Bug 32612: (QA follow-up) Remove more unneeded appender lines 2023-02-03 10:30:04 -03:00
marc21-retrieval-info-auth-dom.xml Bug 27198: Fix syntax in marc21-retrieval-info-auth-dom.xml 2024-04-05 11:51:14 +02:00
marc21-retrieval-info-bib-dom.xml Bug 17871: (followup) Remove zebra::* from the packages templates 2017-02-07 17:50:42 +00:00
plack.psgi Bug 36149: Unset userenv from middleware 2024-05-14 15:04:36 -03:00
SIPconfig.xml Bug 33580: Bring back ability to mark item as seen via SIP2 item information request 2023-05-12 11:22:47 -03:00
unimarc-retrieval-info-auth-dom.xml
unimarc-retrieval-info-bib-dom.xml Bug 17871: (followup) Remove zebra::* from the packages templates 2017-02-07 17:50:42 +00:00
zebra-authorities-dom-site.cfg.in Bug 12216: One should be able to override zebra config 2015-08-03 11:59:03 -03:00
zebra-biblios-dom-site.cfg.in Bug 12216: One should be able to override zebra config 2015-08-03 11:59:03 -03:00
zebra.passwd.in