Commit Graph

15 Commits

Author SHA1 Message Date
Kyle M Hall 400435d4fb Bug 36560: (QA follow-up) Tidy code
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 5f2807b370)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-11-20 23:30:20 +00:00
David Cook b8214ffb4a Bug 36560: Add a CSRF exception for ILS-DI API
This change adds an exception for the ILS-DI API for CSRF prevention since there is no way to acquire a CSRF token
for the ILS-DI API.

1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ILS-DI
2. Enable "ILS-DI"
3. curl -v localhost:8080/cgi-bin/koha/ilsdi.pl -d "service=AuthenticatePatron&username=REALUSER&password=REALPASSWORD"
4. Note the 403 response

5. Apply the patch
6. sudo koha-plack --restart kohadev

7. curl -v localhost:8080/cgi-bin/koha/ilsdi.pl -d "service=AuthenticatePatron&username=REALUSER&password=REALPASSWORD"
8. Note the 200 response

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8472279d5c)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-11-20 23:30:20 +00:00
Julian Maurice 460a48cf69 Bug 36598: Add comments asking to keep both CSRF checks in sync
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-09-30 15:28:48 +00:00
Victor Grousset/tuxayo ffd03490ac Bug 36863: (QA follow-up): tidy up code
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-07-25 14:20:25 +00:00
Jonathan Druart 13e22ae52c Bug 36863: Deal with non-listed methods in CSRF plack middleware
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-07-25 14:20:25 +00:00
Martin Renvoize 647d5e9a9e Bug 37040: (RMaint follow-up) Restore passing CSRF error
This patch restores the plack.middleware.Koha.CSRF plack env setting to
allow passing to the errorDocument.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 8cd6b43504)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-06-27 16:14:34 +00:00
Matt Blenkinsop e708597417 Bug 37040: (QA follow-up) Tidy file
QA tests were failing for tidyness so this patch addresses that

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit aeabe6c9f6)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-06-27 16:14:34 +00:00
David Cook cd7123734e Bug 37040: Prevent ErrorDocument subrequests from activating CSRF
This change improves the mechanism for preventing the CSRF middleware
being activated by ErrorDocument subrequests.

This change was necessary due to a subtle issue identified by
Bug 37041.

Test plan:
0. Apply the patch
1. Restart Koha
koha-plack --restart kohadev
2. Go to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=9908
3. Log in
4. Note that you get a pretty 403 and not an ugly plain text error
5. Go to http://localhost:8081
6. Fill in the login details, but use the HTML inspector to delete
the csrf_token from the hidden inputs
7. Submit the login
8. Note a pretty 403 page

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit c1ac124176)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2024-06-27 16:14:34 +00:00
Marcel de Rooy e4bb59683f
Bug 36700: Fix underscore in CSRF header
Also change the cache key in template plugin. And the X- header
that had an underscore in svc script.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2024-05-01 13:40:12 +01:00
Tomas Cohen Arazi b7c6c0b502
Bug 36193: Add more request information on Koha::Middleware::CSRF output
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-12 17:47:27 +01:00
Jonathan Druart 22d680d54c
Bug 36148: Fix header name
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:07 +01:00
Jonathan Druart 462d170c8e
Bug 36148: Improve error handling and restore programming errors
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:06 +01:00
David Cook 3e90c5517e
Bug 36148: Add explanatory notes
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:05 +01:00
David Cook d3687f0b62
Bug 36148: Allow Koha::Middleware::CSRF to use error/exception middlewares
This change allows Koha::Middleware::CSRF to use the ErrorDocument and
HTTPExcetions middlewares to display the correct status codes and HTML
documents.

Leveraging Plack environmental variables, we're also able to pass along
data to the error page handlers to show warnings indicating that there
was a missing CSRF token.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:04 +01:00
Jonathan Druart 4bd4b367dd
Bug 36148: Move CSRF check to a Plack middleware
The easiest here is to not empty 'op' but instead redirect to an error
page.

Minor changes: to keep the patch simple it removed the 'dev only' error and
display the error for non-dev installs. It should not be a problem
anyway and will prevent errors to be hidden in the log.
We could make KOHA_ERROR an arrayref, but later (we don't need it now
anyway).

Note that the OPAC still not benefit from a friendly specific error for
invalid token.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:03 +01:00