-
Notifications
You must be signed in to change notification settings - Fork 12
/
store.fga.yaml
100 lines (88 loc) · 2.19 KB
/
store.fga.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
model: |
model
schema 1.1
type user
type document
relations
define viewer: [user, user with temporal_access]
condition temporal_access(grant_time: timestamp, grant_duration: duration, current_time: timestamp) {
current_time < grant_time + grant_duration
}
tuples:
- user: user:bob
relation: viewer
object: document:1
- user: user:anne
relation: viewer
object: document:1
condition:
name: temporal_access
context:
grant_time : "2023-01-01T00:00:00Z"
grant_duration : 1h
- user: user:anne
relation: viewer
object: document:2
condition:
name: temporal_access
context:
grant_time : "2023-01-01T00:00:00Z"
grant_duration : 5s
tests:
- name: Test temporal access
check:
- user: user:anne
object: document:1
context:
current_time: "2023-01-01T00:10:00Z"
assertions:
viewer: true
- user: user:anne
object: document:1
context:
current_time: "2023-01-01T02:00:00Z"
assertions:
viewer: false
- user: user:anne
object: document:2
context:
current_time: "2023-01-01T00:00:09Z"
assertions:
viewer: false
- user: user:bob
object: document:1
assertions:
viewer: true
- name: Test the documents that anne can view
list_objects:
- user: user:anne
type: document
context:
current_time: "2023-01-01T00:00:01Z"
assertions:
viewer:
- document:1
- document:2
- name: Test the users that can view document:1
list_users:
- object: document:1
context:
current_time: "2023-01-01T00:00:01Z"
user_filter:
- type: user
assertions:
viewer:
users:
- user:anne
- user:bob
- name: Test the users that can view document:2
list_users:
- object: document:2
context:
current_time: "2023-01-01T00:00:01Z"
user_filter:
- type: user
assertions:
viewer:
users:
- user:anne