-
Notifications
You must be signed in to change notification settings - Fork 22
/
basicResource.yaml
57 lines (50 loc) · 1.39 KB
/
basicResource.yaml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# yaml-language-server: $schema=https://api.cerbos.dev/latest/cerbos/policy/v1/Policy.schema.json
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: default
# This resource file is reviewed for when checking permissions when a resource
# is of `kind` "basicResource"
resource: basicResource
rules:
# If the `principal`s role is `admin` then all the actions are allowed.
- actions:
- "*"
effect: EFFECT_ALLOW
roles:
- ADMIN
# Any user can create a resource
- actions:
- create
effect: EFFECT_ALLOW
roles:
- USER
# Any user can read a resource as long as it is published or owned by the user
- actions:
- read
effect: EFFECT_ALLOW
roles:
- USER
condition:
match:
any:
of:
- expr: request.resource.attr.isPublished == true
- expr: request.resource.attr.ownerId == request.principal.id
# Only the owner of the resource can update or delete it
- actions:
- update
- delete
effect: EFFECT_ALLOW
roles:
- USER
condition:
match:
expr: request.resource.attr.ownerId == request.principal.id
schemas:
principalSchema:
ref: cerbos:///principal.json
resourceSchema:
ref: cerbos:///basicResource.json
ignoreWhen:
actions:
- create