Bug 37553 - Fix CSRF handling in koha-svc.pl script
Summary: Fix CSRF handling in koha-svc.pl script
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 36192
  Show dependency treegraph
 
Reported: 2024-08-02 01:34 UTC by David Cook
Modified: 2024-09-25 08:33 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00, 24.05.04
Circulation function:


Attachments
Bug 37553: Use CSRF token for authenicated session for POSTing (1.58 KB, patch)
2024-08-02 01:39 UTC, David Cook
Details | Diff | Splinter Review
Bug 37553: Consistently send Csrf-Token in request header (2.07 KB, patch)
2024-08-02 01:50 UTC, David Cook
Details | Diff | Splinter Review
Bug 37553: Tidy to make QA tools happy (1.64 KB, patch)
2024-08-02 02:03 UTC, David Cook
Details | Diff | Splinter Review
Bug 37553: Use CSRF token for authenicated session for POSTing (1.63 KB, patch)
2024-08-02 03:29 UTC, David Nind
Details | Diff | Splinter Review
Bug 37553: Consistently send Csrf-Token in request header (2.12 KB, patch)
2024-08-02 03:29 UTC, David Nind
Details | Diff | Splinter Review
Bug 37553: Tidy to make QA tools happy (1.68 KB, patch)
2024-08-02 03:29 UTC, David Nind
Details | Diff | Splinter Review
Bug 37553: Use CSRF token for authenicated session for POSTing (1.73 KB, patch)
2024-08-02 06:35 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 37553: Consistently send Csrf-Token in request header (2.21 KB, patch)
2024-08-02 06:35 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 37553: Tidy to make QA tools happy (1.78 KB, patch)
2024-08-02 06:35 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2024-08-02 01:34:33 UTC
./misc/migration_tools/koha-svc.pl is broken again, as I think we fixed some other CSRF internals after we fixed koha-svc.pl last. Anyway, it should be an easy fix!
Comment 1 David Cook 2024-08-02 01:39:39 UTC
Created attachment 169968 [details] [review]
Bug 37553: Use CSRF token for authenicated session for POSTing

This change fixes the Koha::SVC to store the CSRF token for
the authenticated session for further POSTing.

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"
Comment 2 David Cook 2024-08-02 01:50:10 UTC
Created attachment 169974 [details] [review]
Bug 37553: Consistently send Csrf-Token in request header

This change consistently sends the Csrf-Token in the request header.
Previously, one POST sent it in the request body, while the other POST
sent it in the request header. Since we're using an API, it's best
for us to always send it in the request header

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"
Comment 3 David Cook 2024-08-02 02:03:39 UTC
Created attachment 169976 [details] [review]
Bug 37553: Tidy to make QA tools happy
Comment 4 David Nind 2024-08-02 03:29:43 UTC
Created attachment 169977 [details] [review]
Bug 37553: Use CSRF token for authenicated session for POSTing

This change fixes the Koha::SVC to store the CSRF token for
the authenticated session for further POSTing.

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2024-08-02 03:29:45 UTC
Created attachment 169978 [details] [review]
Bug 37553: Consistently send Csrf-Token in request header

This change consistently sends the Csrf-Token in the request header.
Previously, one POST sent it in the request body, while the other POST
sent it in the request header. Since we're using an API, it's best
for us to always send it in the request header

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2024-08-02 03:29:48 UTC
Created attachment 169979 [details] [review]
Bug 37553: Tidy to make QA tools happy

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Marcel de Rooy 2024-08-02 06:35:14 UTC
Created attachment 169980 [details] [review]
Bug 37553: Use CSRF token for authenicated session for POSTing

This change fixes the Koha::SVC to store the CSRF token for
the authenticated session for further POSTing.

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
    http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Marcel de Rooy 2024-08-02 06:35:17 UTC
Created attachment 169981 [details] [review]
Bug 37553: Consistently send Csrf-Token in request header

This change consistently sends the Csrf-Token in the request header.
Previously, one POST sent it in the request body, while the other POST
sent it in the request header. Since we're using an API, it's best
for us to always send it in the request header

Test plan:
0. Apply the patch
1. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 > bib-29.xml
2. perl ./misc/migration_tools/koha-svc.pl \
	http://localhost:8081/cgi-bin/koha/svc koha koha 29 bib-29.xml
3. Note that the following appears in STDOUT and there is no 403 error:
"update 29 from bib-29.xml"

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2024-08-02 06:35:19 UTC
Created attachment 169982 [details] [review]
Bug 37553: Tidy to make QA tools happy

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 10 Katrin Fischer 2024-08-02 17:01:46 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 11 Lucas Gass (lukeg) 2024-09-11 15:54:17 UTC
Backported to 24.05.x for upcoming 24.05.04
Comment 12 Fridolin Somers 2024-09-25 08:33:23 UTC
Not for 23.11.x