Koha/debian
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
..
docs Bug 35954: Add --status to koha-plack 2024-05-03 19:31:56 +02:00
scripts Bug 36325: Add --exclude-logs option to koha-run-backups 2024-05-13 14:00:07 +02:00
source Bug 32994: Remove compiled files from src (2) 2023-02-22 10:03:25 -03:00
templates Bug 36149: Unset userenv from middleware 2024-05-14 15:04:36 -03:00
bd-to-depends
build-git-snapshot Bug 33629: allow pbuilder to use network via build-git-snapshot 2023-05-05 09:13:15 -03:00
changelog Update debian/changelog file: 22.12.00-3 2023-02-20 09:44:12 -03:00
clean Bug 32994: Remove compiled files from src (2) 2023-02-22 10:03:25 -03:00
compat
control Bug 36788: Update debian/control file 2024-05-06 15:04:29 +02:00
control.in Bug 25691: Replace link to non-existing README with wiki link 2024-01-16 12:06:08 +01:00
copyright
koha-common.bash-completion Bug 33108: Teach koha-list filter elasticsearch 2023-03-20 09:39:46 -03:00
koha-common.config
koha-common.cron.d
koha-common.cron.daily Bug 19532: (QA follow-up) Add the cron jobs to the cron files 2022-03-14 22:45:52 -10:00
koha-common.cron.hourly Bug 23207: Add automatic checkin feature 2021-04-22 11:11:05 +02:00
koha-common.cron.monthly
koha-common.default
koha-common.dirs
koha-common.docs Bug 35713: Remove outdated debian/docs/LEEME.Debian file 2024-01-11 12:10:45 +01:00
koha-common.init Bug 33108: (follow-up) Don't let restart die if ES indexer not running 2023-03-20 09:39:48 -03:00
koha-common.install Bug 33108: koha-es-indexer added 2023-03-20 09:39:45 -03:00
koha-common.links
koha-common.logrotate
koha-common.postinst Bug 35242: Force memcache restart after koha upgrade 2023-11-03 12:04:44 -03:00
koha-common.preinst
koha-common.README.Debian
koha-common.service Bug 33371: Add [Install] section to koha-common.service 2023-06-01 11:55:28 -03:00
koha-common.templates
koha-core.bash-completion Bug 33108: Teach koha-list filter elasticsearch 2023-03-20 09:39:46 -03:00
koha-core.config Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.default Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.dirs Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.docs Bug 35713: Remove outdated debian/docs/LEEME.Debian file 2024-01-11 12:10:45 +01:00
koha-core.init Bug 32922: (follow-up) Fix two additional occurences 2023-02-20 09:44:07 -03:00
koha-core.install Bug 33108: koha-es-indexer added 2023-03-20 09:39:45 -03:00
koha-core.links Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.logrotate Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.postinst Bug 32612: (QA follow-up) Remove more unneeded appender lines 2023-02-03 10:30:04 -03:00
koha-core.preinst Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-core.templates Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-full.postinst Bug 26672: Add additional koha-core and koha-full files to ./debian 2020-11-25 16:18:03 +01:00
koha-post-install-setup
koha.apache-ports
koha.config
koha.dirs
koha.install
koha.postinst Bug 25691: Replace link to non-existing README with wiki link 2024-01-16 12:06:08 +01:00
koha.postrm
koha.prerm
koha.README.Debian
list-deps Bug 29882: remove unrequired package definitions in list-deps script 2022-09-07 13:17:59 -07:00
README.build
rules Bug 33168: (follow-up) Swap spaces for tabs 2023-04-04 11:26:20 +02:00
unavailable.html
update-control

In order to build .deb packages, following debian packages need to be present
(installed): 
devscripts
pbuilder
dh-make
fakeroot

As root (or sudo) execute:
pbuilder create

Executing build-git-snapshot without any arguments will leave package and the
rest in some pbuilder dir, eg. /var/cache/pbuilder/result It is highly
recommended that --buildresult option is used.