Bug 11666: add permission check for MARC framework import/export

This patch makes the MARC framework import/export script require
that the staff user be logged in with appropriate permissions for
managing the MARC frameworks.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

I can confirm the bug and the solution. After applying the patch
downloading the file without logging in first is no longer possible.
Also passes tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 03d4ed2468)
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit 412b761e27)
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
(cherry picked from commit 412b761e27)
This commit is contained in:
Galen Charlton 2014-02-04 15:54:33 +00:00 committed by Bernardo Gonzalez Kriegel
parent 28a30b6bd8
commit b2f0f7c8fa
1 changed files with 20 additions and 0 deletions

View File

@ -21,11 +21,31 @@
use strict;
use warnings;
use CGI;
use CGI::Cookie;
use C4::Context;
use C4::Auth qw/check_cookie_auth/;
use C4::ImportExportFramework;
my %cookies = CGI::Cookie->fetch();
my $authenticated = 0;
my ($auth_status, $sessionID);
if (exists $cookies{'CGISESSID'}) {
($auth_status, $sessionID) = check_cookie_auth(
$cookies{'CGISESSID'}->value,
{ parameters => 'parameters_remaining_permissions' },
);
}
if ($auth_status eq 'ok') {
$authenticated = 1;
}
my $input = new CGI;
unless ($authenticated) {
print $input->header(-type => 'text/plain', -status => '403 Forbidden');
exit 0;
}
my $frameworkcode = $input->param('frameworkcode') || '';
my $action = $input->param('action') || 'export';