File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -10,28 +10,37 @@ schema: |-
1010 day_of_week == 'tuesday'
1111 }
1212
13+ caveat ip_allowlist(user_ip ipaddress, cidr string) {
14+ user_ip.in_cidr(cidr)
15+ }
16+
1317 definition document {
1418 /**
15- * reader indicates that the user is a reader on the document, either directly
16- * or only on tuesday.
19+ * reader indicates that the user is a reader on the document, either directly,
20+ * only on tuesday, or from allowed IPs .
1721 */
18- relation reader: user | user with only_on_tuesday
22+ relation reader: user | user with only_on_tuesday | user with ip_allowlist
1923
2024 permission view = reader
2125 }
2226relationships : |-
2327 document:firstdoc#reader@user:fred
2428 document:firstdoc#reader@user:tom[only_on_tuesday]
29+ document:firstdoc#reader@user:alice[ip_allowlist:{"cidr":"1.2.3.0/24"}]
2530assertions :
2631 assertTrue :
2732 - ' document:firstdoc#view@user:tom with {"day_of_week": "tuesday"}'
2833 - " document:firstdoc#view@user:fred"
34+ - ' document:firstdoc#view@user:alice with {"user_ip": "1.2.3.4"}'
2935 assertCaveated :
3036 - " document:firstdoc#view@user:tom"
37+ - " document:firstdoc#view@user:alice"
3138 assertFalse :
3239 - ' document:firstdoc#view@user:tom with {"day_of_week": "wednesday"}'
40+ - ' document:firstdoc#view@user:alice with {"user_ip": "8.8.8.8"}'
3341validation :
3442 document:firstdoc#view:
3543 - " [user:fred] is <document:firstdoc#reader>"
3644 - " [user:tom[...]] is <document:firstdoc#reader>"
45+ - " [user:alice[...]] is <document:firstdoc#reader>"
3746 document:seconddoc#view: []
You can’t perform that action at this time.
0 commit comments