]> git.sesse.net Git - itkacl/blob - itkacl-web-1.0/web/add.pl
Protect the web interface against CSRF, and the CSRF token against BREACH.
[itkacl] / itkacl-web-1.0 / web / add.pl
1 #! /usr/bin/perl -T
2 use strict;
3 use warnings;
4 use utf8;
5
6 use lib '../include';
7 use itkaclcommon;
8
9 itkaclcommon::init();
10 itkaclcommon::check_csrf_token();
11
12 my $allow = $itkaclcommon::cgi->param('allow');
13 my $entry = $itkaclcommon::cgi->param('entry');
14 my $entity = $itkaclcommon::cgi->param('entity');
15 my $entity_type = $itkaclcommon::cgi->param('entity_type');
16 my $comment = $itkaclcommon::cgi->param('comment');
17
18 $itkaclcommon::dbh->do('INSERT INTO aclentries (allow,object,entity_type,entity,comment) VALUES (?,?,?,?,?)', undef,
19     $allow, $entry, $entity_type, $entity, $comment)
20         or die "Couldn't add new ACL entry";
21
22 # Let sync-itkacl know there's updates
23 utime(time(), time(), '/etc/itkacl/updated');
24         
25 print $itkaclcommon::cgi->redirect("view.pl?entry=$entry");
26