-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimpl.py
42 lines (30 loc) · 1.27 KB
/
impl.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
from resources import Resource
from security.security_manager import require_permissions
from security.authzed_resource import AuthzedResourceType
from security.permissions import AuthzedAction
class ResourceA(Resource):
def __init__(self, name, tags):
super().__init__(name, tags)
def get_type(self) -> AuthzedResourceType:
return AuthzedResourceType.A
@require_permissions(actions=[AuthzedAction.READ])
def read_protected(self):
print(f"Calling read_protected on {self.name}")
@require_permissions(actions=[AuthzedAction.EDIT])
def edit_protected(self):
print(f"Calling edit_protected on {self.name}")
def unprotected(self):
print(f"Calling unprotected on {self.name}")
class ResourceB(Resource):
def __init__(self, name, tags):
super().__init__(name, tags)
def get_type(self) -> AuthzedResourceType:
return AuthzedResourceType.B
@require_permissions(actions=[AuthzedAction.READ])
def read_protected(self):
print(f"Calling read_protected on {self.name}")
@require_permissions(actions=[AuthzedAction.EDIT])
def edit_protected(self):
print(f"Calling edit_protected on {self.name}")
def unprotected(self):
print(f"Calling unprotected on {self.name}")