question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combine priority and deny-override models

See original GitHub issue

Hi Dev team,

you’ve recently added explicit priority model support in 1.9.0, many thanks for that.

Is there any chance to support two policy effects at once? For example Priority model with deny override. Something like:

[policy_effect]
e = (priority(p.eft) || deny) || (!some(where (p.eft == deny))) 

The value of support such a combined policy effect is that users can have multiple groups assigned with a different eff (allow, deny) and not be dependant on policy position in the file. Please see the example below.

model.conf

[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

policy.csv

p, 10, data1_deny_group, data1, write, deny
p, 10, data1_allow_group, data1, write, allow

g, alice, data1_deny_group
g, alice, data1_allow_group

enforcement result of e.Enforce(“alice”, “data1”, “write”) will be false, because both groups have the same priority and in this case, Casbin takes the first one, that is deny.

However, if we switch policy and have a policy file like:

policy.csv

p, 10, data1_allow_group, data1, write, allow
p, 10, data1_deny_group, data1, write, deny

g, alice, data1_deny_group
g, alice, data1_allow_group

The result of enforcement - e.Enforce(“alice”, “data1”, “write”)
will be Allow, as first is allow policy.


In such cases, when there’re multiple groups with the same priority, combine Priority and deny-override models. For example, when enforcement happens, casbin can realize that there’re multiple matching policies with the same priority, and in such cases it can additionally apply a deny-override effect?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
apiscevscommented, Jul 7, 2021

Hello Sagilio, maybe you have any insights on when presumably this might be added to the Casbin.Net toolbelt? The thing is that we’re starting a new project soon, and having this feature is one of the core requirements.

Thanks, Alex

1reaction
sagiliocommented, Jul 6, 2021

I think this feature can be supported. I have not edit permission for the issue now. @hsluoyz @xcaptain

Read more comments on GitHub >

github_iconTop Results From Across the Web

Casbin
You can customize your own access control model by combining the available models. For example, you can get RBAC roles and ABAC attributes...
Read more >
Resolving Policy Conflicts - Integrating ...
Our proposed model allows different policy authorities to provide their individual ... priority the top policy combining algorithm can't be DenyOverrides or.
Read more >
Rules and combining algorithms - PingAuthorize - 9.2
Policies can include one or more rules to produce a fine-grained authorization decision of Permit , Deny , Indeterminate , or Not Applicable ......
Read more >
Priority Mail Regional Rate Boxes A and B will be Discontinued
They were created to combine the speed and convenience of Priority Mail and Priority Mail International ® shipping with zone pricing to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found