Koha/debian/templates
Jonathan Druart c97d9db239 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>
(cherry picked from commit 3dd1cdd74f)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-05-01 15:35:19 +00:00
..
apache-shared-disable.conf
apache-shared-intranet-plack.conf Bug 27421: Commit and revert 2022-09-19 15:14:56 -03:00
apache-shared-intranet.conf Bug 36322: Redirect docs dir to 404 2024-03-26 15:57:23 +00:00
apache-shared-opac-plack.conf Bug 21267: Set X-FORWARDED-PROTO https if required 2018-08-31 12:46:58 +00: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 16520: Add new Plack-SetEnv syntax to Apache configuration files 2016-10-11 12:37:16 +00:00
apache-site-https.conf.in Bug 34193: SSLProtocol enable in use versions and disable deprecated versions 2023-08-21 20:23:12 -10: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
koha-conf-site.xml.in Bug 30843: Add mfa_range configuration option for TOTP 2023-10-05 08:36:20 -10: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
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-01 15:35:19 +00: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