1 Peak Security
Here's a brief example of how to use peak security.
1.1 A short example
1
2 from peak.api import *
3
4 class Owner(security.Permission):
5 pass
6
7 class Building(object):
8
9 security.allow(
10 burnBuilding = Owner
11 )
12
13 def burnBuilding(self):
14 print "Burn baby burn"
15
16 class buildingRules(security.RuleSet):
17
18 rules = Items(
19 checkCanBurn = [Owner.of(Building)]
20 )
21
22 def checkCanBurn(self, attempt):
23 if attempt.user is attempt.subject.owner:
24 return 1
25 else:
26 return security.Denial(
27 "You are not allowed to burn that building"
28 )
29
30 BuildingRules.declareRulesFor(security.IPermissionChecker)