File: EditControlRule.pm

package info (click to toggle)
libapache2-sitecontrol-perl 1.05-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, forky, sid, trixie
  • size: 208 kB
  • sloc: perl: 558; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package EditControlRule;

use Apache2::SiteControl::Rule;

@ISA = qw(Apache2::SiteControl::Rule);

# This rule is going to be used in a system that automatically grants
# permission for everything (via the GrantAllRule). So this rule will
# only worry about what to deny, and the grants method can return whatever.
# Note that writing a deny-based system is inherently more dangerous and 
# buggy because of the lack of type-safety. Typos in the HTML components can
# cause a rule to fail to deny an invalid request, which is typically less
# desirable than failing to grant a request. The former is a security hole that
# might get missed; the latter is a bug that gets quickly reported.
sub grants($$$$)
{
   return 0;
}

sub denies($$$$)
{
   my ($this, $user, $action, $resource) = @_;

   return 1 if($action eq "edit" && $user->getUsername ne "admin");

   return 0;
}

1;