
Hello,
It seems that I stuck in the middle with trivial issue. Hope you'll help me with a guidance.
Trying to build a model for REST API authorisation with an option to override "parent" permission.
Option 1
Test model:
[request_definition]
r = subj, obj, act
[policy_definition]
p = subj, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = priority(p.eft) || deny
[matchers]
m = (g(r.subj, p.subj) || (r.subj == p.subj)) && regexMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
Test policy:
p, alice, /foo/bar/.+/.+baz.+, GET, allow
p, alice, /foo/bar/.+/baz$, GET, deny
p, alice, /foo/bar/.+, GET, allow
p, alice, /foo/bar.+, GET, deny
p, alice, /foo/bar$, GET, allow
p, alice, /foo/.+, GET, deny
p, alice, /foo.+, GET, deny
p, data2_admin, /foo$, GET, allow
p, alice, /.+, GET, deny
g, alice, data2_admin
Test requests:
alice, /zed, GET
alice, /zed, POST
alice, /foo, GET
data2_admin, /foo, GET
alice, /foo-bar, GET
alice, /foo/zed, GET
alice, /foo/bar, GET
alice, /foo/bar-zed, GET
alice, /foo/bar/zed, GET
alice, /foo/bar/*/baz-q, GET
alice, /foo/bar/zed/baz, GET
alice, /foo/bar/*/*baz*, GET
alice, /foo/bar/zed/aaa-baz=val, GET
Everything woks as expected BUT the longest (most precise) rule should be added on top of rules list.
So, "priority" needs to be in place in particular here:
1. p, alice, /foo/bar/.+/.+baz.+, GET, allow
2. p, alice, /foo/bar/.+/baz$, GET, deny
3. p, alice, /foo/bar/.+, GET, allow
for
alice, /foo/bar/*/baz-q, GET ---> true
alice, /foo/bar/zed/baz, GET ---> false
How should be and addition of any new more specific rule handled if there is no option for "numbered insertion" for any new particular rule? For example there is a new REST API endpoint and new authorisation rule needed.
Let's say I need "rule zero on top of existing list"
0. p, alice, /foo/bar/.+/.+baz-q$, GET, deny
1. p, alice, /foo/bar/.+/.+baz.+, GET, allow
2. p, alice, /foo/bar/.+/baz$, GET, deny
3. p, alice, /foo/bar/.+, GET, allow
Should it be done aside of Casbin and then policy reloaded forcibly by Casbin server? Or there is more convenient way?
p.s. actually it is somewhat alike to #290
Option 2
Everything is the same but Effector is "allow-override"
Test model:
[request_definition]
r = subj, obj, act
[policy_definition]
p = subj, obj, act, eft
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = (g(r.subj, p.subj) || (r.subj == p.subj)) && regexMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
Test policy:
p, alice, /foo/bar/.+/.+baz.+, GET, allow
p, alice, /foo/bar/.+/baz$, GET, deny
p, alice, /foo/bar/.+, GET, allow
p, alice, /foo/bar.+, GET, deny
p, alice, /foo/bar$, GET, allow
p, alice, /foo/.+, GET, deny
p, alice, /foo.+, GET, deny
p, data2_admin, /foo$, GET, allow
p, alice, /.+, GET, deny
g, alice, data2_admin
Test requests:
alice, /zed, GET
alice, /zed, POST
alice, /foo, GET
data2_admin, /foo, GET
alice, /foo-bar, GET
alice, /foo/zed, GET
alice, /foo/bar, GET
alice, /foo/bar-zed, GET
alice, /foo/bar/zed, GET
alice, /foo/bar/*/baz-q, GET
alice, /foo/bar/zed/baz, GET
alice, /foo/bar/*/*baz*, GET
alice, /foo/bar/zed/aaa-baz=val, GET
With this Effector in place result is different:
alice, /foo/bar/*/baz-q, GET ---> true
alice, /foo/bar/zed/baz, GET ---> true
Second request is improperly (or am I wrong?) rendered to "true" also.
And here I think it would be nice to be able to choose "longest/precise match", that is request
described more precisely by the
regex rule rather than
What I try to achieve is that no matter the order of the policy rules examined, most precise rule should be chosen as a result.
or
Ability to re-balance policy rules list during create/update/delete operations with those rules to comply with "priority eft".
Or did I chose effector and matcher in a wrong way?
Any input would be appreciated.
Thanks.
IssueHunt Summary
closetool has been rewarded.
Backers (Total: $21.00)
hsluoyz ($1.00)
- $20.00 have been anonymously funded.
Submitted pull Requests
Tips
Hello,
It seems that I stuck in the middle with trivial issue. Hope you'll help me with a guidance.
Trying to build a model for REST API authorisation with an option to override "parent" permission.
Option 1
Test model:
Test policy:
Test requests:
alice, /zed, GET alice, /zed, POST alice, /foo, GET data2_admin, /foo, GET alice, /foo-bar, GET alice, /foo/zed, GET alice, /foo/bar, GET alice, /foo/bar-zed, GET alice, /foo/bar/zed, GET alice, /foo/bar/*/baz-q, GET alice, /foo/bar/zed/baz, GET alice, /foo/bar/*/*baz*, GET alice, /foo/bar/zed/aaa-baz=val, GETEverything woks as expected BUT the longest (most precise) rule should be added on top of rules list.
So, "priority" needs to be in place in particular here:
for
How should be and addition of any new more specific rule handled if there is no option for "numbered insertion" for any new particular rule? For example there is a new REST API endpoint and new authorisation rule needed.
Let's say I need "rule zero on top of existing list"
Should it be done aside of Casbin and then policy reloaded forcibly by Casbin server? Or there is more convenient way?
p.s. actually it is somewhat alike to #290
Option 2
Everything is the same but Effector is "allow-override"
Test model:
Test policy:
Test requests:
alice, /zed, GET alice, /zed, POST alice, /foo, GET data2_admin, /foo, GET alice, /foo-bar, GET alice, /foo/zed, GET alice, /foo/bar, GET alice, /foo/bar-zed, GET alice, /foo/bar/zed, GET alice, /foo/bar/*/baz-q, GET alice, /foo/bar/zed/baz, GET alice, /foo/bar/*/*baz*, GET alice, /foo/bar/zed/aaa-baz=val, GETWith this Effector in place result is different:
Second request is improperly (or am I wrong?) rendered to "true" also.
And here I think it would be nice to be able to choose "longest/precise match", that is request
described more precisely by the
regex rule rather than
What I try to achieve is that no matter the order of the policy rules examined, most precise rule should be chosen as a result.
or
Ability to re-balance policy rules list during create/update/delete operations with those rules to comply with "priority eft".
Or did I chose effector and matcher in a wrong way?
Any input would be appreciated.
Thanks.
IssueHunt Summary
Backers (Total: $21.00)
Submitted pull Requests
Tips