What's your scenario? What do you want to achieve?
As I read in documents, by default Casbin designed to prioritize rules by given definition order (1); and also there is a way to add priority in rules definitions (2). But what I need in my app is to be able to prioritize by roles/users levels; and as levels could be infinite, I can't use the (2) approach, cause in every change I need to change all priority levels.
Is there a way to prioritze based on hierarchy level currently? If no, is it possible to implement a feature for this?
Your model:
[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
Your policy:
p, admin, posts, create, allow
p, admin, posts, remove, allow
p, editor, posts, create, allow
p, editor, posts, remove, deny
p, subscriber, posts, create, deny
p, subscriber, posts, remove, deny
p, jane, posts, remove, allow
g, jane, editor
g, john, subscriber
Your request(s):
jane, posts, create ---> true
jane, posts, remove ---> false (expected: true)
john, posts, create ---> false
john, posts, remove ---> false
What's your scenario? What do you want to achieve?
As I read in documents, by default Casbin designed to prioritize rules by given definition order (1); and also there is a way to add priority in rules definitions (2). But what I need in my app is to be able to prioritize by roles/users levels; and as levels could be infinite, I can't use the (2) approach, cause in every change I need to change all priority levels.
Is there a way to prioritze based on hierarchy level currently? If no, is it possible to implement a feature for this?
Your model:
Your policy:
Your request(s):