-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from sagilio/fix#199
feat: Implement priority explicit deny override model for v2
- Loading branch information
Showing
17 changed files
with
263 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
NetCasbin.UnitTest/examples/priority_explicit_deny_override_model.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) && !some(where (p_eft == deny)) | ||
|
||
[matchers] | ||
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act |
10 changes: 10 additions & 0 deletions
10
NetCasbin.UnitTest/examples/priority_explicit_deny_override_policy.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 | ||
|
||
|
||
g, bob, data2_allow_group | ||
g, alice, data2_allow_group | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Collections.Generic; | ||
using Casbin.Effect; | ||
|
||
namespace Casbin | ||
{ | ||
internal struct EnforceSession | ||
{ | ||
internal IReadOnlyList<object> RequestValues { get; set; } | ||
internal IReadOnlyList<string> PolicyValues { get; set; } | ||
|
||
internal string ExpressionString { get; set; } | ||
|
||
internal int PolicyIndex { get; set; } | ||
internal int PolicyCount { get; set; } | ||
|
||
internal PolicyEffect PolicyEffect { get; set; } | ||
internal PolicyEffect[] PolicyEffects { get; set; } | ||
|
||
internal bool Determined { get; private set; } | ||
internal bool EnforceResult { get; set; } | ||
|
||
internal EffectExpressionType EffectExpressionType { get; set; } | ||
internal bool ExpressionResult { get; set; } | ||
|
||
internal bool IsChainEffector { get; set; } | ||
internal bool HasPriority { get; set; } | ||
internal int PriorityIndex { get; set; } | ||
internal int? Priority { get; set; } | ||
|
||
internal void DetermineResult(bool result) | ||
{ | ||
Determined = true; | ||
EnforceResult = result; | ||
} | ||
} | ||
} |
Oops, something went wrong.