Bug 20701: Add csrf protection to mancredit.pl
Works OK.
Signed-off-by: Amit Gupta <amit.gupta@informaticsglobal.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit fb083c95a2)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
cce493764a
commit
163a1f4d42
|
|
@ -36,6 +36,7 @@ $(document).ready(function(){
|
|||
|
||||
<form action="/cgi-bin/koha/members/mancredit.pl" method="post" id="mancredit">
|
||||
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
|
||||
<input type="hidden" name="csrf_token" value="[% csrf_token %]" />
|
||||
|
||||
<fieldset class="rows">
|
||||
<legend>Manual credit</legend><ol>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
|
|||
use Koha::Patron::Images;
|
||||
|
||||
use Koha::Patron::Categories;
|
||||
use Koha::Token;
|
||||
|
||||
my $input=new CGI;
|
||||
my $flagsrequired = { borrowers => 1, updatecharges => 1 };
|
||||
|
|
@ -48,6 +49,15 @@ my $add=$input->param('add');
|
|||
|
||||
if ($add){
|
||||
if ( checkauth( $input, 0, $flagsrequired, 'intranet' ) ) {
|
||||
|
||||
die "Wrong CSRF token"
|
||||
unless Koha::Token->new->check_csrf( {
|
||||
session_id => $input->cookie('CGISESSID'),
|
||||
token => scalar $input->param('csrf_token'),
|
||||
});
|
||||
|
||||
# Note: If the logged in user is not allowed to see this patron an invoice can be forced
|
||||
# Here we are trusting librarians not to hack the system
|
||||
my $barcode = $input->param('barcode');
|
||||
my $itemnum;
|
||||
if ($barcode) {
|
||||
|
|
@ -99,6 +109,9 @@ if ($add){
|
|||
borrowernumber => $borrowernumber,
|
||||
categoryname => $data->{'description'},
|
||||
is_child => ($data->{'category_type'} eq 'C'),
|
||||
csrf_token => Koha::Token->new->generate_csrf(
|
||||
{ session_id => scalar $input->cookie('CGISESSID') }
|
||||
),
|
||||
);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue