This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo-v1-Demo.policy
72 lines (66 loc) · 1.89 KB
/
demo-v1-Demo.policy
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
policy "admin" {
rules {
*allow_method($0)
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, $0)
@ $0 in ["Create", "Delete", "Read", "Status", "Update"]
}
caveats {[
*authorized($0)
<- allow_method(#authority, $0)
||
*authorized($0)
<- method(#ambient, $0),
env(#ambient, $1)
@ $1 in ["DEV", "STG"]
], [
*authorized_server($2)
<- service(#ambient, $2)
@ prefix($2, "demo.api.v1")
]}
}
policy "auditor" {
caveats {[
*allow_dev()
<- arg(#ambient, "env", "DEV")
]}
}
policy "developer" {
rules {
*allow_method("Status")
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, "Status")
*allow_method($0)
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, $0),
arg(#ambient, "env", "DEV")
@ $0 in ["Create", "Delete"]
*allow_method($0)
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, $0),
arg(#ambient, "env", $1)
@ $0 in ["Read", "Update"],
$1 in ["DEV", "STG"]
*allow_method("Read")
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, "Read"),
arg(#ambient, "env", "PRD"),
arg(#ambient, "entities.name", $3)
@ $3 in ["entity1", "entity2", "entity3"]
}
caveats {[
*authorized($0)
<- allow_method(#authority, $0)
]}
}
policy "guest" {
rules {
*allow_method("Status")
<- service(#ambient, "demo.api.v1.Demo"),
method(#ambient, "Status")
}
caveats {[
*authorized($0)
<- allow_method(#authority, $0)
]}
}