From 64db96053a212cdcc62f9f4137f096ea2f73af04 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Wed, 29 May 2019 22:46:18 +0530 Subject: [PATCH] Bug 22990: Add CSRF protection to basketheader.pl Test plan 1. Create vendor 2. Create basket using the form
3. You can able to create the basket. 4. Apply the patch. 5. Create basket using the form 6. Now you can get error "The form submission failed (Wrong CSRF token). Try to come back, refresh the page, then try again." Signed-off-by: Martin Renvoize Signed-off-by: David Cook Bug 22990: Add CSRF protection to Koha pages Signed-off-by: David Cook --- acqui/basketheader.pl | 3 +++ .../prog/en/modules/acqui/basketheader.tt | 3 ++- .../prog/en/modules/members/boraccount.tt | 11 +++++++---- .../intranet-tmpl/prog/en/modules/members/pay.tt | 1 + .../prog/en/modules/suggestion/suggestion.tt | 4 ++++ members/boraccount.pl | 15 ++++++++++----- members/pay.pl | 7 +++++++ members/setstatus.pl | 1 + suggestion/suggestion.pl | 7 +++++-- 9 files changed, 40 insertions(+), 12 deletions(-) diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index e79daa70a7..284963847e 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -141,6 +141,9 @@ if ( $op eq 'add_form' ) { #End Edit } elsif ( $op eq 'add_validate' ) { #we are confirming the changes, save the basket +#we are checking CSRF Token. + output_and_exit_if_error($input, $cookie, $template, { check => 'csrf_token' }); + if ( $is_an_edit ) { ModBasketHeader( $basketno, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt index 4db81b1650..81b2ea70f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt @@ -50,13 +50,14 @@
- + [% INCLUDE 'blocking_errors.inc' %] [% IF ( add_form ) %] [% IF ( basketno ) %]

Edit basket [% basketname | html %]

[% ELSE %]

Add a basket to [% booksellername | html %]

[% END %]
+ [% INCLUDE 'csrf-token.inc' %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index 592cac4ad5..aea116bf1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -45,7 +45,7 @@ [% INCLUDE 'members-toolbar.inc' %]

    Account for [% INCLUDE 'patron-title.inc' %]

    - +
    [% INCLUDE 'csrf-token.inc' %]
    @@ -116,14 +116,14 @@ [% END %] Details [% IF account.is_debit && account.amountoutstanding > 0 %] - Pay + Pay [% END %] [% IF account.is_credit && account.status != 'VOID' %] - Void payment + Void payment [% END %] [% IF account.is_debit && account.amount == account.amountoutstanding && account.status != 'CANCELLED' && !(account.debit_type_code == 'PAYOUT') %]
    - + [% INCLUDE 'csrf-token.inc' %]