bug 7688: (follow-up) add authentication checking
authorGalen Charlton <gmc@esilibrary.com>
Wed, 30 Oct 2013 02:51:11 +0000 (02:51 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 30 Oct 2013 02:51:11 +0000 (02:51 +0000)
A couple web services introduced in the patch series
lacked authentication checks.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

serials/create-numberpattern.pl
serials/subscription-numberpattern.pl

index 8aa967e..9bf2300 100755 (executable)
@@ -1,14 +1,20 @@
 #!/usr/bin/perl
 
+use Modern::Perl;
 use CGI;
 use C4::Context;
 use C4::Serials::Numberpattern;
+use C4::Auth qw/check_cookie_auth/;
 use URI::Escape;
-use strict;
-use warnings;
 
 my $input = new CGI;
 
+my ($auth_status, $sessionID) = check_cookie_auth($input->cookie('CGISESSID'), { serials => '*' });
+if ($auth_status ne "ok") {
+    print $input->header(-type => 'text/plain', -status => '403 Forbidden');
+    exit 0;
+}
+
 my $numberpattern;
 foreach (qw/ numberingmethod label1 label2 label3 add1 add2 add3
   every1 every2 every3 setto1 setto2 setto3 whenmorethan1 whenmorethan2
index c54f264..4cd280a 100755 (executable)
@@ -1,12 +1,19 @@
 #!/usr/bin/perl
 
+use Modern::Perl;
 use CGI;
 use C4::Serials::Numberpattern;
+use C4::Auth qw/check_cookie_auth/;
 use URI::Escape;
-use strict;
-use warnings;
 
 my $input=new CGI;
+
+my ($auth_status, $sessionID) = check_cookie_auth($input->cookie('CGISESSID'), { serials => '*' });
+if ($auth_status ne "ok") {
+    print $input->header(-type => 'text/plain', -status => '403 Forbidden');
+    exit 0;
+}
+
 my $numpatternid=$input->param("numberpattern_id");
 
 my $numberpatternrecord=GetSubscriptionNumberpattern($numpatternid);