snapshot of https://github.com/casbin/casbin.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
Build / test (1.21) (push) Successful in 2m21s
Build / benchmark (1.21) (push) Failing after 2m28s
golangci-lint / golangci (push) Successful in 19m40s

This commit is contained in:
upstream-mirror
2026-09-15 21:46:19 +05:00
commit d8971e16fb
234 changed files with 28137 additions and 0 deletions

11
examples/abac_model.conf Normal file
View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == r.obj.Owner

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act, eft
[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
[matchers]
m = r.sub == r.obj.Owner

View File

@@ -0,0 +1,4 @@
p, alice, /data1, read, deny
p, alice, /data1, write, allow
p, bob, /data2, write, deny
p, bob, /data2, read, allow
1 p alice /data1 read deny
2 p alice /data1 write allow
3 p bob /data2 write deny
4 p bob /data2 read allow

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub_rule, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = eval(p.sub_rule) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, r.sub.Age > 18, /data1, read
p, r.sub.Age < 60, /data2, write
1 p r.sub.Age > 18 /data1 read
2 p r.sub.Age < 60 /data2 write

View File

@@ -0,0 +1,2 @@
p, alice, data1, write
p, bob, data2, read
1 p alice data1 write
2 p bob data2 read

11
examples/basic_model.conf Normal file
View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub,obj,act
[policy_definition]
p = sub,obj,act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, alice, data1, read
p, bob, data2, write
1 p alice data1 read
2 p bob data2 write

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act || r.sub == "root"

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, act
[policy_definition]
p = sub, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, alice, read
p, bob, write
1 p alice read
2 p bob write

View File

@@ -0,0 +1,11 @@
[request_definition]
r = obj, act
[policy_definition]
p = obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, data1, read
p, data2, write
1 p data1 read
2 p data2 write

14
examples/biba_model.conf Normal file
View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, sub_level, obj, obj_level, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m =(r.act == "read" && r.sub_level <= r.obj_level) || (r.act == "write" && r.sub_level >= r.obj_level)

14
examples/blp_model.conf Normal file
View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, sub_level, obj, obj_level, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = (r.act == "read" && r.sub_level >= r.obj_level) || (r.act == "write" && r.sub_level <= r.obj_level)

View File

@@ -0,0 +1,12 @@
[request_definition]
r = sub, obj, act ; Request definition
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow)) # This is policy effect.
# Matchers
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, alice, data1, read
bob, data2, write
1 p, alice, data1, read
2 bob, data2, write

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub_rule, obj_rule, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = eval(p.sub_rule) && eval(p.obj_rule) && (p.act == '*' || r.act == p.act)

View File

@@ -0,0 +1 @@
p, r.sub == 'admin' || false, r.obj == 'users', write
1 p r.sub == 'admin' || false r.obj == 'users' write

11
examples/glob_model.conf Normal file
View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && globMatch(r.obj, p.obj) && r.act == p.act

4
examples/glob_policy.csv Normal file
View File

@@ -0,0 +1,4 @@
p, u1, /foo/*, read
p, u2, /foo*, read
p, u3, /*/foo/*, read
p, u4, *, read
1 p u1 /foo/* read
2 p u2 /foo* read
3 p u3 /*/foo/* read
4 p u4 * read

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = ipMatch(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,2 @@
p, 192.168.2.0/24, data1, read
p, 10.0.0.0/16, data2, write
1 p 192.168.2.0/24 data1 read
2 p 10.0.0.0/16 data2 write

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && keyGet2(r.obj, p.obj, 'resource') in ('age', 'name') && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && (r.obj == p.obj || keyGet(r.obj, p.obj) in ('age','name')) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,2 @@
p, alice, /alice_data/:resource, GET
p, alice, /alice_data2/:id/using/:resId, GET
1 p alice /alice_data/:resource GET
2 p alice /alice_data2/:id/using/:resId GET

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && keyMatchCustom(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,7 @@
p, alice, /alice_data/*, GET
p, alice, /alice_data/resource1, POST
p, bob, /alice_data/resource2, GET
p, bob, /bob_data/*, POST
p, cathy, /cathy_data, (GET)|(POST)
1 p alice /alice_data/* GET
2 p alice /alice_data/resource1 POST
3 p bob /alice_data/resource2 GET
4 p bob /bob_data/* POST
5 p cathy /cathy_data (GET)|(POST)

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && keyMatch(r.dom, p.dom) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,6 @@
g, can_manage, can_use, *
p, can_manage, engines/*, *, (pause)|(resume)
p, can_use, engines/*, *, (attach)|(detach)
g, Username==test2, can_manage, engines/engine1
1 g, can_manage, can_use, *
2 p, can_manage, engines/*, *, (pause)|(resume)
3 p, can_use, engines/*, *, (attach)|(detach)
4 g, Username==test2, can_manage, engines/engine1

14
examples/lbac_model.conf Normal file
View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, subject_confidentiality, subject_integrity, obj, object_confidentiality, object_integrity, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = (r.act == "read" && r.subject_confidentiality >= r.object_confidentiality && r.subject_integrity >= r.object_integrity) || (r.act == "write" && r.subject_confidentiality <= r.object_confidentiality && r.subject_integrity <= r.object_integrity)

View File

@@ -0,0 +1,19 @@
[request_definition]
r = sub, obj, act
r2 = sub, obj, act
[policy_definition]
p = sub, obj, act
p2= sub_rule, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
#RABC
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
#ABAC
m2 = eval(p2.sub_rule) && r2.obj == p2.obj && r2.act == p2.act

View File

@@ -0,0 +1,5 @@
p, data2_admin, data2, read
p2, r2.sub.Age > 18 && r2.sub.Age < 60, /data1, read, allow
p2, r2.sub.Age > 60 && r2.sub.Age < 100, /data1, read, deny
g, alice, data2_admin
1 p, data2_admin, data2, read
2 p2, r2.sub.Age > 18 && r2.sub.Age < 60, /data1, read, allow
3 p2, r2.sub.Age > 60 && r2.sub.Age < 100, /data1, read, deny
4 g, alice, data2_admin

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, sub_rule, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && eval(p.sub_rule) && r.act == p.act

View File

@@ -0,0 +1,5 @@
p, alice, r.obj.price < 25, read
p, admin, r.obj.category_id = 2, read
p, bob, r.obj.author = bob, write
g, alice, admin
1 p, alice, r.obj.price < 25, read
2 p, admin, r.obj.category_id = 2, read
3 p, bob, r.obj.author = bob, write
4 g, alice, admin

16
examples/orbac_model.conf Normal file
View File

@@ -0,0 +1,16 @@
[request_definition]
r = sub, org, obj, act
[policy_definition]
p = role, activity, view, org
[role_definition]
g = _, _, _
g2 = _, _, _
g3 = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.role, r.org) && g2(r.act, p.activity, r.org) && g3(r.obj, p.view, r.org) && r.org == p.org

25
examples/orbac_policy.csv Normal file
View File

@@ -0,0 +1,25 @@
# Permission rules: role, activity, view, organization
p, manager, modify, document, org1
p, manager, consult, document, org1
p, employee, consult, document, org1
p, manager, modify, report, org2
p, manager, consult, report, org2
p, employee, consult, report, org2
# Empower: subject, role, organization
g, alice, manager, org1
g, bob, employee, org1
g, charlie, manager, org2
g, david, employee, org2
# Use: action, activity, organization
g2, write, modify, org1
g2, read, consult, org1
g2, write, modify, org2
g2, read, consult, org2
# Consider: object, view, organization
g3, data1, document, org1
g3, data2, document, org1
g3, report1, report, org2
g3, report2, report, org2
1 # Permission rules: role, activity, view, organization
2 p, manager, modify, document, org1
3 p, manager, consult, document, org1
4 p, employee, consult, document, org1
5 p, manager, modify, report, org2
6 p, manager, consult, report, org2
7 p, employee, consult, report, org2
8 # Empower: subject, role, organization
9 g, alice, manager, org1
10 g, bob, employee, org1
11 g, charlie, manager, org2
12 g, david, employee, org2
13 # Use: action, activity, organization
14 g2, write, modify, org1
15 g2, read, consult, org1
16 g2, write, modify, org2
17 g2, read, consult, org2
18 # Consider: object, view, organization
19 g3, data1, document, org1
20 g3, data2, document, org1
21 g3, report1, report, org2
22 g3, report2, report, org2

11
examples/pbac_model.conf Normal file
View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub_rule, obj_rule, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = eval(p.sub_rule) && eval(p.obj_rule) && r.act == p.act

2
examples/pbac_policy.csv Normal file
View File

@@ -0,0 +1,2 @@
p, r.sub.Role == 'admin', r.obj.Type == 'doc', read
p, r.sub.Age >= 18, r.obj.Type == 'video', play
1 p r.sub.Role == 'admin' r.obj.Type == 'doc' read
2 p r.sub.Age >= 18 r.obj.Type == 'video' play

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.obj) && keyMatch4(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1 @@
p, alice, data1, read, indeterminate
1 p alice data1 read indeterminate

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = priority(p.eft) || deny
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,16 @@
[request_definition]
r = sub, obj, act
r2 = sub, obj
[policy_definition]
p = sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = priority(p.eft) || deny
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
m2 = g(r2.sub, p.sub)

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = priority, sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = priority(p.eft) || deny
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,14 @@
[request_definition]
r = subject, obj, act
[policy_definition]
p = customized_priority, obj, act, eft, subject
[role_definition]
g = _, _
[policy_effect]
e = priority(p.eft) || deny
[matchers]
m = g(r.subject, p.subject) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,12 @@
p, alice, data1, read, allow
p, data1_deny_group, data1, read, deny
p, data1_deny_group, data1, write, deny
p, alice, data1, write, allow
g, alice, data1_deny_group
p, data2_allow_group, data2, read, allow
p, bob, data2, read, deny
p, bob, data2, write, deny
g, bob, data2_allow_group
1 p, alice, data1, read, allow
2 p, data1_deny_group, data1, read, deny
3 p, data1_deny_group, data1, write, deny
4 p, alice, data1, write, allow
5 g, alice, data1_deny_group
6 p, data2_allow_group, data2, read, allow
7 p, bob, data2, read, deny
8 p, bob, data2, write, deny
9 g, bob, data2_allow_group

View File

@@ -0,0 +1,12 @@
p, alice, data1, read, allow
p, data1_deny_group, data1, read, deny
p, data1_deny_group, data1, write, deny
p, alice, data1, write, allow
g, alice, data1_deny_group
p, data2_allow_group, data2, read, allow
p, bob, data2, read, deny
p, bob, data2, write, deny
g, bob, data2_allow_group
1 p, alice, data1, read, allow
2 p, data1_deny_group, data1, read, deny
3 p, data1_deny_group, data1, write, deny
4 p, alice, data1, write, allow
5 g, alice, data1_deny_group
6 p, data2_allow_group, data2, read, allow
7 p, bob, data2, read, deny
8 p, bob, data2, write, deny
9 g, bob, data2_allow_group

View File

@@ -0,0 +1,12 @@
p, 10, data1_deny_group, data1, read, deny
p, 10, data1_deny_group, data1, write, deny
p, 10, data2_allow_group, data2, read, allow
p, 10, data2_allow_group, data2, write, allow
p, 1, alice, data1, write, allow
p, 1, alice, data1, read, allow
p, 1, bob, data2, read, deny
g, bob, data2_allow_group
g, alice, data1_deny_group
1 p 10 data1_deny_group data1 read deny
2 p 10 data1_deny_group data1 write deny
3 p 10 data2_allow_group data2 read allow
4 p 10 data2_allow_group data2 write allow
5 p 1 alice data1 write allow
6 p 1 alice data1 read allow
7 p 1 bob data2 read deny
8 g bob data2_allow_group
9 g alice data1_deny_group

View File

@@ -0,0 +1,12 @@
p, 10, data1, read, deny, data1_deny_group
p, 10, data1, write, deny, data1_deny_group
p, 10, data2, read, allow, data2_allow_group
p, 10, data2, write, allow, data2_allow_group
p, 1, data1, write, allow, alice
p, 1, data1, read, allow, alice
p, 1, data2, read, deny, bob
g, bob, data2_allow_group
g, alice, data1_deny_group
1 p 10 data1 read deny data1_deny_group
2 p 10 data1 write deny data1_deny_group
3 p 10 data2 read allow data2_allow_group
4 p 10 data2 write allow data2_allow_group
5 p 1 data1 write allow alice
6 p 1 data1 read allow alice
7 p 1 data2 read deny bob
8 g bob data2_allow_group
9 g alice data1_deny_group

14
examples/rbac_model.conf Normal file
View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj \
&& r.act == p.act

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3')

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ['data2', 'data3']

5
examples/rbac_policy.csv Normal file
View File

@@ -0,0 +1,5 @@
p, alice, data1, read
p, bob, data2, write
p, data2_admin, data2, read
p, data2_admin, data2, write
g, alice, data2_admin
1 p, alice, data1, read
2 p, bob, data2, write
3 p, data2_admin, data2, read
4 p, data2_admin, data2, write
5 g, alice, data2_admin

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act, ctx
[policy_definition]
p = sub, obj, act, cond, eft
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && keyMatch(r.act, p.act) && eval(p.cond)

View File

@@ -0,0 +1,20 @@
# RBAC roles combined with a per-policy ABAC condition.
#
# p, role, object, action, cond, effect
#
# "cond" is a matcher expression evaluated against the ctx argument of the
# request. Write "true" for a policy that carries no condition. A cond may only
# read attributes that every request reaching it actually supplies: reading an
# attribute the ctx does not have makes Enforce return an error rather than a
# plain "denied", so pass a struct (or a map with every attribute filled in).
p, employee, data1, read, r.ctx.Hour >= 9 && r.ctx.Hour < 18, allow
p, employee, data2, write, r.ctx.Secure == true, allow
p, admin, data3, read, true, allow
# Deny overrides every allow above: a high-risk session gets nothing.
p, employee, *, *, r.ctx.Risk == 'high', deny
g, admin, employee
g, alice, admin
g, bob, employee
Can't render this file because it contains an unexpected character in line 5 and column 3.

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && g(r.obj, p.obj, r.dom) && r.dom == p.dom && r.act == p.act

View File

@@ -0,0 +1,4 @@
p, alice, domain1, book_group, read
p, alice, domain2, book_group, write
g, /book/:id, book_group, *
1 p, alice, domain1, book_group, read
2 p, alice, domain2, book_group, write
3 g, /book/:id, book_group, *

View File

@@ -0,0 +1,20 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[constraint_definition]
c = sod("finance_requester", "finance_approver")
c2 = sodMax(["payroll_view", "payroll_edit", "payroll_approve"], 1)
c3 = roleMax("superadmin", 2)
c4 = rolePre("db_admin", "security_trained")
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,7 @@
p, alice, data1, read
p, bob, data2, write
p, data2_admin, data2, read
p, data2_admin, data2, write
g, alice, data2_admin
g, data2_admin, super_admin
g, super_admin, alice
1 p, alice, data1, read
2 p, bob, data2, write
3 p, data2_admin, data2, read
4 p, data2_admin, data2, write
5 g, alice, data2_admin
6 g, data2_admin, super_admin
7 g, super_admin, alice

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,7 @@
p, alice, data1, read, allow
p, bob, data2, write, allow
p, data2_admin, data2, read, allow
p, data2_admin, data2, write, allow
p, alice, data2, write, deny
g, alice, data2_admin
1 p, alice, data1, read, allow
2 p, bob, data2, write, allow
3 p, data2_admin, data2, read, allow
4 p, data2_admin, data2, write, allow
5 p, alice, data2, write, deny
6 g, alice, data2_admin

View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _, (_, _)
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, p.dom) && g2(r.obj, p.dom) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,12 @@
p, role:owner, domain1, _, (read|write)
p, role:developer, domain1, _, read
p, role:owner, domain2, _, (read|write)
p, role:developer, domain2, _, read
g, alice, role:owner, domain1, _, _
g, bob, role:developer, domain2, _, 9999-12-30 00:00:00
g, carol, role:owner, domain2, _, 0000-01-02 00:00:00
g2, data1, domain1
g2, data2, domain2
1 p, role:owner, domain1, _, (read|write)
2 p, role:developer, domain1, _, read
3 p, role:owner, domain2, _, (read|write)
4 p, role:developer, domain2, _, read
5 g, alice, role:owner, domain1, _, _
6 g, bob, role:developer, domain2, _, 9999-12-30 00:00:00
7 g, carol, role:owner, domain2, _, 0000-01-02 00:00:00
8 g2, data1, domain1
9 g2, data2, domain2

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,8 @@
p, admin, domain1, data1, read
p, admin, domain1, data1, write
p, admin, domain2, data2, read
p, admin, domain2, data2, write
p, admin, *, data3, read
g, alice, admin, *
g, bob, admin, domain2
1 p, admin, domain1, data1, read
2 p, admin, domain1, data1, write
3 p, admin, domain2, data2, read
4 p, admin, domain2, data2, write
5 p, admin, *, data3, read
6 g, alice, admin, *
7 g, bob, admin, domain2

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _, (_, _)
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,24 @@
p, alice, domain1, data1, read
p, alice, domain1, data1, write
p, data2_admin, domain2, data2, read
p, data2_admin, domain2, data2, write
p, data3_admin, domain3, data3, read
p, data3_admin, domain3, data3, write
p, data4_admin, domain4, data4, read
p, data4_admin, domain4, data4, write
p, data5_admin, domain5, data5, read
p, data5_admin, domain5, data5, write
p, data6_admin, domain6, data6, read
p, data6_admin, domain6, data6, write
p, data7_admin, domain7, data7, read
p, data7_admin, domain7, data7, write
p, data8_admin, domain8, data8, read
p, data8_admin, domain8, data8, write
g, alice, data2_admin, domain2, 0000-01-01 00:00:00, 0000-01-02 00:00:00
g, alice, data3_admin, domain3, 0000-01-01 00:00:00, 9999-12-30 00:00:00
g, alice, data4_admin, domain4, _, _
g, alice, data5_admin, domain5, _, 9999-12-30 00:00:00
g, alice, data6_admin, domain6, _, 0000-01-02 00:00:00
g, alice, data7_admin, domain7, 0000-01-01 00:00:00, _
g, alice, data8_admin, domain8, 9999-12-30 00:00:00, _
1 p alice domain1 data1 read
2 p alice domain1 data1 write
3 p data2_admin domain2 data2 read
4 p data2_admin domain2 data2 write
5 p data3_admin domain3 data3 read
6 p data3_admin domain3 data3 write
7 p data4_admin domain4 data4 read
8 p data4_admin domain4 data4 write
9 p data5_admin domain5 data5 read
10 p data5_admin domain5 data5 write
11 p data6_admin domain6 data6 read
12 p data6_admin domain6 data6 write
13 p data7_admin domain7 data7 read
14 p data7_admin domain7 data7 write
15 p data8_admin domain8 data8 read
16 p data8_admin domain8 data8 write
17 g alice data2_admin domain2 0000-01-01 00:00:00 0000-01-02 00:00:00
18 g alice data3_admin domain3 0000-01-01 00:00:00 9999-12-30 00:00:00
19 g alice data4_admin domain4 _ _
20 g alice data5_admin domain5 _ 9999-12-30 00:00:00
21 g alice data6_admin domain6 _ 0000-01-02 00:00:00
22 g alice data7_admin domain7 0000-01-01 00:00:00 _
23 g alice data8_admin domain8 9999-12-30 00:00:00 _

View File

@@ -0,0 +1,5 @@
p, role_top, domainx, data_top, read
p, role_solo, domainx, data_solo, read
g, alice, role_mid, domainx, _, _
g, role_mid, role_top, domainx, 0000-01-01 00:00:00, 0000-01-02 00:00:00
g, alice, role_solo, domainx, 0000-01-01 00:00:00, 0000-01-02 00:00:00
1 p, role_top, domainx, data_top, read
2 p, role_solo, domainx, data_solo, read
3 g, alice, role_mid, domainx, _, _
4 g, role_mid, role_top, domainx, 0000-01-01 00:00:00, 0000-01-02 00:00:00
5 g, alice, role_solo, domainx, 0000-01-01 00:00:00, 0000-01-02 00:00:00

View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _, (_, _)
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && \
(keyMatch(r.act, p.act) || keyMatch2(r.act, p.act) || keyMatch3(r.act, p.act) || keyMatch4(r.act, p.act) || keyMatch5(r.act, p.act) || globMatch(r.act, p.act))

View File

@@ -0,0 +1,13 @@
p, test1, domain1, service1, /list
p, test1, domain1, service1, /get/:id/*
p, test1, domain1, service1, /add
p, test1, domain1, service1, /user/*
p, admin, domain1, service1, /*
p, qa1, domain2, service2, /broadcast
p, qa1, domain2, service2, /trip
p, qa1, domain2, service2, /notify
p, qa1, domain2, service2, /dynamic-sql
g, alice, test1, domain1, _, 2999-12-30 00:00:00
g, bob, qa1, domain2, _, 2999-12-30 00:00:00
g, jack, test1, domain1, _, 0000-12-30 00:00:00
1 p test1 domain1 service1 /list
2 p test1 domain1 service1 /get/:id/*
3 p test1 domain1 service1 /add
4 p test1 domain1 service1 /user/*
5 p admin domain1 service1 /*
6 p qa1 domain2 service2 /broadcast
7 p qa1 domain2 service2 /trip
8 p qa1 domain2 service2 /notify
9 p qa1 domain2 service2 /dynamic-sql
10 g alice test1 domain1 _ 2999-12-30 00:00:00
11 g bob qa1 domain2 _ 2999-12-30 00:00:00
12 g jack test1 domain1 _ 0000-12-30 00:00:00

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, dom, obj, act
[policy_definition]
p = sub, dom, obj, act
[role_definition]
g = _, _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,6 @@
p, admin, domain1, data1, read
p, admin, domain1, data1, write
p, admin, domain2, data2, read
p, admin, domain2, data2, write
g, alice, admin, domain1
g, bob, admin, domain2
1 p, admin, domain1, data1, read
2 p, admin, domain1, data1, write
3 p, admin, domain2, data2, read
4 p, admin, domain2, data2, write
5 g, alice, admin, domain1
6 g, bob, admin, domain2

View File

@@ -0,0 +1,9 @@
p, admin, domain1, data1, read
p, admin, domain1, data1, write
p, admin, domain2, data2, read
p, admin, domain2, data2, write
p, user, domain3, data2, read
g, alice, admin, domain1
g, alice, admin, domain2
g, bob, admin, domain2
g, bob, user, domain3
1 p, admin, domain1, data1, read
2 p, admin, domain1, data1, write
3 p, admin, domain2, data2, read
4 p, admin, domain2, data2, write
5 p, user, domain3, data2, read
6 g, alice, admin, domain1
7 g, alice, admin, domain2
8 g, bob, admin, domain2
9 g, bob, user, domain3

View File

@@ -0,0 +1,10 @@
p, alice, data1, read
p, bob, data2, write
p, data1_admin, data1, read
p, data1_admin, data1, write
p, data2_admin, data2, read
p, data2_admin, data2, write
g, alice, admin
g, admin, data1_admin
g, admin, data2_admin
1 p, alice, data1, read
2 p, bob, data2, write
3 p, data1_admin, data1, read
4 p, data1_admin, data1, write
5 p, data2_admin, data2, read
6 p, data2_admin, data2, write
7 g, alice, admin
8 g, admin, data1_admin
9 g, admin, data2_admin

View File

@@ -0,0 +1,11 @@
p, role:reader, domain1, data1, read
p, role:writer, domain1, data1, write
p, alice, domain1, data2, read
p, alice, domain2, data2, read
g, role:global_admin, role:reader, domain1
g, role:global_admin, role:writer, domain1
g, alice, role:global_admin, domain1
1 p, role:reader, domain1, data1, read
2 p, role:writer, domain1, data1, write
3 p, alice, domain1, data2, read
4 p, alice, domain2, data2, read
5 g, role:global_admin, role:reader, domain1
6 g, role:global_admin, role:writer, domain1
7 g, alice, role:global_admin, domain1

View File

@@ -0,0 +1,17 @@
[request_definition]
r = user, thing, action
[policy_definition]
p = role, thing, action
p2 = role, action
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.user, p.role) && r.thing == p.thing && r.action == p.action
m2 = g(r.user, p2.role) && r.action == p.action
[role_definition]
g = _,_
g2 = _,_

View File

@@ -0,0 +1,9 @@
p, user, /data, GET
p, admin, /data, POST
p2, user, view
p2, admin, create
g, admin, user
g, alice, admin
g2, alice, user
1 p, user, /data, GET
2 p, admin, /data, POST
3 p2, user, view
4 p2, admin, create
5 g, admin, user
6 g, alice, admin
7 g2, alice, user

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = !some(where (p.eft == deny))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && g2(r.obj, p.obj) && regexMatch(r.act, p.act)

View File

@@ -0,0 +1,28 @@
p, alice, /pen/1, GET
p, alice, /pen2/1, GET
p, book_admin, book_group, GET
p, pen_admin, pen_group, GET
p, *, pen3_group, GET
p, /book/admin/:id, pen4_group, GET
g, /book/user/:id, /book/admin/1
p, /book/leader/2, pen4_group, POST
g, /book/user/:id, /book/leader/2
g, alice, book_admin
g, bob, pen_admin
g, cathy, /book/1/2/3/4/5
g, cathy, pen_admin
g2, /book/*, book_group
g2, /book/:id, book_group
g2, /pen/:id, pen_group
g2, /book2/{id}, book_group
g2, /pen2/{id}, pen_group
g2, /pen3/:id, pen3_group
g2, /pen4/:id, pen4_group
1 p, alice, /pen/1, GET
2 p, alice, /pen2/1, GET
3 p, book_admin, book_group, GET
4 p, pen_admin, pen_group, GET
5 p, *, pen3_group, GET
6 p, /book/admin/:id, pen4_group, GET
7 g, /book/user/:id, /book/admin/1
8 p, /book/leader/2, pen4_group, POST
9 g, /book/user/:id, /book/leader/2
10 g, alice, book_admin
11 g, bob, pen_admin
12 g, cathy, /book/1/2/3/4/5
13 g, cathy, pen_admin
14 g2, /book/*, book_group
15 g2, /book/:id, book_group
16 g2, /pen/:id, pen_group
17 g2, /book2/{id}, book_group
18 g2, /pen2/{id}, pen_group
19 g2, /pen3/:id, pen3_group
20 g2, /pen4/:id, pen4_group

View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && g2(r.obj, p.obj) && r.act == p.act

View File

@@ -0,0 +1,7 @@
p, alice, data1, read
p, bob, data2, write
p, data_group_admin, data_group, write
g, alice, data_group_admin
g2, data1, data_group
g2, data2, data_group
1 p, alice, data1, read
2 p, bob, data2, write
3 p, data_group_admin, data_group, write
4 g, alice, data_group_admin
5 g2, data1, data_group
6 g2, data2, data_group

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _, (_, _)
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,24 @@
p, alice, data1, read
p, alice, data1, write
p, data2_admin, data2, read
p, data2_admin, data2, write
p, data3_admin, data3, read
p, data3_admin, data3, write
p, data4_admin, data4, read
p, data4_admin, data4, write
p, data5_admin, data5, read
p, data5_admin, data5, write
p, data6_admin, data6, read
p, data6_admin, data6, write
p, data7_admin, data7, read
p, data7_admin, data7, write
p, data8_admin, data8, read
p, data8_admin, data8, write
g, alice, data2_admin, 0000-01-01 00:00:00, 0000-01-02 00:00:00
g, alice, data3_admin, 0000-01-01 00:00:00, 9999-12-30 00:00:00
g, alice, data4_admin, _, _
g, alice, data5_admin, _, 9999-12-30 00:00:00
g, alice, data6_admin, _, 0000-01-02 00:00:00
g, alice, data7_admin, 0000-01-01 00:00:00, _
g, alice, data8_admin, 9999-12-30 00:00:00, _
1 p alice data1 read
2 p alice data1 write
3 p data2_admin data2 read
4 p data2_admin data2 write
5 p data3_admin data3 read
6 p data3_admin data3 write
7 p data4_admin data4 read
8 p data4_admin data4 write
9 p data5_admin data5 read
10 p data5_admin data5 write
11 p data6_admin data6 read
12 p data6_admin data6 write
13 p data7_admin data7 read
14 p data7_admin data7 write
15 p data8_admin data8 read
16 p data8_admin data8 write
17 g alice data2_admin 0000-01-01 00:00:00 0000-01-02 00:00:00
18 g alice data3_admin 0000-01-01 00:00:00 9999-12-30 00:00:00
19 g alice data4_admin _ _
20 g alice data5_admin _ 9999-12-30 00:00:00
21 g alice data6_admin _ 0000-01-02 00:00:00
22 g alice data7_admin 0000-01-01 00:00:00 _
23 g alice data8_admin 9999-12-30 00:00:00 _

15
examples/rebac_model.conf Normal file
View File

@@ -0,0 +1,15 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = role, obj_type, act
[role_definition]
g = _, _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, r.obj, p.role) && g2(r.obj, p.obj_type) && r.act == p.act

View File

@@ -0,0 +1,7 @@
p, collaborator, doc, read
g, alice, doc1, collaborator
g, bob, doc2, collaborator
g2, doc1, doc
g2, doc2, doc
1 p, collaborator, doc, read
2 g, alice, doc1, collaborator
3 g, bob, doc2, collaborator
4 g2, doc1, doc
5 g2, doc2, doc

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = subjectPriority(p.eft) || deny
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,14 @@
[request_definition]
r = sub, obj, dom, act
[policy_definition]
p = sub, obj, dom, act, eft #sub can't change position,must be first
[role_definition]
g = _, _, _
[policy_effect]
e = subjectPriority(p.eft) || deny
[matchers]
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act

View File

@@ -0,0 +1,16 @@
p, root, data1, read, deny
p, admin, data1, read, deny
p, editor, data1, read, deny
p, subscriber, data1, read, deny
p, jane, data1, read, allow
p, alice, data1, read, allow
g, admin, root
g, editor, admin
g, subscriber, admin
g, jane, editor
g, alice, subscriber
1 p, root, data1, read, deny
2 p, admin, data1, read, deny
3 p, editor, data1, read, deny
4 p, subscriber, data1, read, deny
5 p, jane, data1, read, allow
6 p, alice, data1, read, allow
7 g, admin, root
8 g, editor, admin
9 g, subscriber, admin
10 g, jane, editor
11 g, alice, subscriber

View File

@@ -0,0 +1,7 @@
p, admin, data1, domain1, write, deny
p, alice, data1, domain1, write, allow
p, admin, data2, domain2, write, deny
p, bob, data2, domain2, write, allow
g, alice, admin, domain1
g, bob, admin, domain2
1 p, admin, data1, domain1, write, deny
2 p, alice, data1, domain1, write, allow
3 p, admin, data2, domain2, write, deny
4 p, bob, data2, domain2, write, allow
5 g, alice, admin, domain1
6 g, bob, admin, domain2

View File

@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p_eft == allow))
[matchers]
m = r.sub == "a.p.p.l.e"