Commit graph

52519 commits

Author SHA1 Message Date
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
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
82359cf085
Bug 36084: svc - overdrive
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:02 +01:00
6323e08ed7
Bug 36084: Fix file upload and www/batch.t
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:01 +01:00
e19c978f02
Bug 36084: svc - mana
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:01 +01:00
2f44827bc1
Bug 36084: (follow-up) svc - localization
This form is never sent.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:01:00 +01:00
74a0961081
Bug 36084: (follow-up) svc - config/systempreferences
This form is never sent.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:59 +01:00
99d776f58e
Bug 36084: svc - renew
Material - The code that is supposed to replace the checkbox with a text
was not at the correct place. It should be with checkin, not renewal.
With the table refresh it does not make sense to keep it as we will
never see it.
Best is to replace the checkbox with the text directly.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:58 +01:00
d4ce4d8fa2
Bug 36084: svc - recall
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:57 +01:00
25ea67c2ca
Bug 36084: svc - problem_reports
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:56 +01:00
bf3e4ec999
Bug 36084: svc - virtualshelves/search
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:55 +01:00
e3e288c7be
Bug 36084: svc - members/add_to_list
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:55 +01:00
dfe3fcde90
Bug 36084: svc - localization
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:54 +01:00
8ebb11b244
Bug 36084: svc - creator_batches
No desire to have a nice api client for this.

This patch also:
Improve failure handling
Remove unecessary code in svc script
Remove duplicated on click binding

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:53 +01:00
374db28eee
Bug 36084: svc - cover_images
Removing the ability to remove several cover images, it was not used.

FIXME - Note that I am getting randomly a failure when uploading an image and
seeing the following error in the log:
[Wed Feb 21 10:43:59.168934 2024] [cgi:error] [pid 24037] [client 172.18.0.1:45074] AH01215: Use of uninitialized value $fileID in bitwise and (&) at /kohadevbox/koha/tools/upload-cover-image.pl line 101.: /kohadevbox/koha/tools/upload-cover-image.pl, referer: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=1

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:52 +01:00
0fe82b601b
Bug 36084: Add CSRF token support to svc/authentication
GET svc/authentication will return a CSRF token in a response header

POST svc/authentication requires a CSRF token which can be sourced
from the response header of GET svc/authentication or some other
place like the meta element on a HTML page

Note: misc/migration_tools/koha-svc.pl is a simple script which
can be used to practically evaluate svc/authentication and svc/bib

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:51 +01:00
61f1f88c5c
Bug 36084: svc - clubs
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:50 +01:00
3fb8940b5a
Bug 36084: svc - checkout_notes - OPAC
Decided to not use APIClient for OPAC, LATER.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:49 +01:00
526ceeb4fa
Bug 36084: svc - checkout_notes
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:49 +01:00
6a9ff124a5
Bug 36084: Fix is_ajax by setting X-Requested-With header
Some svc scripts (and controllers) are using using is_ajax to guess if
it's an AJAX request.
$.ajax is setting the (non standard) X-Requested-With header, but the
low level JS 'fetch' does not.

This patch set it in http-client.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:48 +01:00
50f383de75
Bug 36084: svc - checkin
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:47 +01:00
d322494ef6
Bug 36084: svc - config/systempreferences
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:46 +01:00
52d0005ae0
Bug 36084: svc - shelfbrowser.pl - Replace with GET
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:45 +01:00
40cfd29b83
Bug 36084: svc - authorised_values - APIClient now global
APIClient is not a global variable, which will make the next changes
much easier!

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:44 +01:00
8b1871f5cf
Bug 36084: Do not allow absence of token
Well, this test was silly, I was focussed on propagating an error to the
UI, but we really need to explode in this case.

Note that this requires more work as login is now broken.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:44 +01:00
20528b5efc
Bug 36084: Add a global #messages div
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:43 +01:00
39843c2325
Bug 36084: Add a Dialog class
To display potential errors.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:42 +01:00
a9851c0d8b
Bug 36084: Bring fetch for everywhere
We are retrieving the awesome fetch modules from Vue, so that it can be
used in other areas. Here we will use it to inject the CSRF token to the
header of every POST request.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:41 +01:00
cb64ea0c54
Bug 36084: svc - article_request - POC
This is a proof of concept

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:40 +01:00
c6c8b66b74
Bug 36084: C4::Auth+plack.psgi for svc?
Suggestion to move the CSRF check to CGI->new so that we will check it
for every request, and it will cover svc scripts as well (they are not
using get_template_and_user).

The token will be retrieve from the param list *or the csrf_token
header* (do we want to name it x-koha-csrf-token instead?).

This will be done for *every* request that are not GET: CSRF token is now
required everywhere CGI is used (side-effects possible?).

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:39 +01:00
59ae5d7b6d
Bug 36102: (follow-up 2) Add cud-login to the login form - fix tests
Bug 36102: [TO SQUASH] (follow-up 2) Add cud-login to the login form - fix tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:38 +01:00
e345d34ae5
Bug 36102: Add cud-login to the login form (2FA)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:38 +01:00
2529a9d3a6
Bug 36102: (follow-up) Add cud-login to the login form
Previous patch missed opac-auth

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:37 +01:00
b2855e26d4
Bug 36102: Fix removal of cookie from the installer session on upgrades
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:36 +01:00
a44a01aaf3
Bug 36102: Fix expired session on the login page of the installer (?)
I *think* this change fixes a bug when starting the installer with an
expired session. I am no longer able to reproduce the problem however.

Just skip if it does not make sense.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:35 +01:00
59470197c2
Bug 36102: If CSRF check fails, try with anonymous
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:34 +01:00
591646d090
Bug 36102: Remove cookie from the installer session
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:33 +01:00
919d0d4c02
Bug 36102: Generate a new sessionID if the existing one is invalid
If the cookie contain an expired sessionID we need to create another
one to correctly generate the CSRF token.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:33 +01:00
e533d5745c
Bug 36102: Do not repeat op or csrf_token on the login form - staff
Needed for OPAC?

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:32 +01:00
5b82d61477
Bug 36102: (follow-up) Add cud-login to the login form
Hum this didn't make sense. We are not checking credentials after
checkauth.

This patch is suggesting to rename "userid" and "password" parameters
from login forms to "login_userid" and "login_password" to not interfere
with other parameters with the same name.

This looks quite correct, however I am seeing
  "The form submission failed (Wrong CSRF token)."
in the log after a successful login. Which feels wrong, what's
happening?

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:31 +01:00
8f5782cf70
Bug 36102: Do not keep op and csrf_token in param list after login - OPAC
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:30 +01:00
74511d87b5
Bug 36102: Fix 01-installation.t
Something very weird is happening here.

There is a FIXME already, but the trick does not seem to work anymore
(?)

This patch contains some debug statements and take some screenshots.
We are reaching the cud-selectframeworks step then we are expecting the
form to submit the form with op=cud-addframeworks

BUT it seems that "op" is empty, and there is an unexpected warning from
Starman:

==> /var/log/koha/kohadev/plack-error.log <==
""
Use of uninitialized value in string ne at /usr/share/perl5/Starman/Server.pm line 304.

==> /var/log/koha/kohadev/plack-intranet-error.log <==
[2024/02/15 13:09:34] [WARN] Warning: something's wrong at /kohadevbox/koha/installer/install.pl line 89.

What's going on here??

UPDATE: This is fixed by "Bug 34478: Manual fix - Make Koha::Token use
session id not userenv id"

Bug 36102: [TO SQUASH] Fix 01-installation.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:29 +01:00
fabbd8f940
Bug 36102: Use Koha::Session from C4::InstallAuth
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:28 +01:00
88797c54b0
Bug 36102: Add cud-login to the login form
TODO This needs to be covered by tests.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:27 +01:00
8a20c96b6f
Bug 34478: serials/routing-preview.pl
Not totally done, still need the "save and preview"

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:27 +01:00
18b046598c
Bug 34478: (follow-up) Move resend link out of form for display reasons
This improves display. This only comes up when you try to reset your
password after you did already.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:26 +01:00
c9375e746b
Bug 34478: (follow-up) Manual fix - Make Koha::Token use session id not userenv id
See comment 174.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:25 +01:00
f859c30704
Bug 34478: Fix www/auth_values_input_www.t
See bug 36189, we need to rewrite this using Selenium.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:24 +01:00
bb54d3f1ce
Bug 34478: Manual fix - reopen basket - add cud- - basket.tt
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:23 +01:00
ff4b63d5c5
Bug 34478: Add cud to updatestructure
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2024-03-01 11:00:22 +01:00