forked from casbin/Casbin.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Better support tokens with substring relation and use two more …
…complex test cases (casbin#319) * fix: err filter logic Signed-off-by: sagilio <sagilio@outlook.com> * docs: updated broken links and formatting (casbin#305) * docs: updated broken links * docs: formatting * Update README.md Co-authored-by: hsluoyz <hsluoyz@qq.com> * feat: Support tokens with substring relation Signed-off-by: Yuan <2912363476@qq.com> * feat: Support tokens with substring relation Signed-off-by: Yuan <2912363476@qq.com> * feat: Support tokens with substring relation Signed-off-by: Tan <2912363476@qq.com> * fix: Fixed an invalid test case Signed-off-by: Tan <2912363476@qq.com> --------- Signed-off-by: sagilio <sagilio@outlook.com> Signed-off-by: Yuan <2912363476@qq.com> Signed-off-by: Tan <2912363476@qq.com> Co-authored-by: sagilio <sagilio@outlook.com> Co-authored-by: r4wand <26229485+r4wand@users.noreply.github.com> Co-authored-by: hsluoyz <hsluoyz@qq.com>
- Loading branch information
1 parent
fe9c386
commit 520bb17
Showing
8 changed files
with
123 additions
and
12 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
15 changes: 15 additions & 0 deletions
15
Casbin.UnitTests/examples/tokens_with_substring_relation_abac.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,15 @@ | ||
[request_definition] | ||
r = sub, 1sub, 1sub2 | ||
|
||
[policy_definition] | ||
p = sub, 1sub, 1sub2 | ||
|
||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
|
||
[matchers] | ||
m = (eval(p.sub) && r.1sub.Name == p.1sub &&r.1sub2 == p.1sub2) || r.sub.Name == r.1sub.Owner | ||
|
||
#sub is sub | ||
#1sub is obj | ||
#1sub2 is act |
2 changes: 2 additions & 0 deletions
2
Casbin.UnitTests/examples/tokens_with_substring_relation_abac.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,2 @@ | ||
p, r.sub.Age > 18, data1, read | ||
p, r.sub.Age < 60, data2, write |
19 changes: 19 additions & 0 deletions
19
Casbin.UnitTests/examples/tokens_with_substring_relation_rbac.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,19 @@ | ||
[request_definition] | ||
r = sub, 1sub, sub2, 1sub2 | ||
|
||
[policy_definition] | ||
p = sub, 1sub, sub2, 1sub2 | ||
|
||
[role_definition] | ||
g = _, _, _ | ||
|
||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
|
||
[matchers] | ||
m = g(r.sub, p.sub, r.1sub) && r.1sub == p.1sub && ((r.sub2 == p.sub2 && r.1sub2 == p.1sub2 ) || (r.sub2 == "freeread" && r.1sub2 == "read")) | ||
# m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act | ||
#sub is sub | ||
#1sub is dom | ||
#sub2 is obj | ||
#1sub2 is act |
5 changes: 5 additions & 0 deletions
5
Casbin.UnitTests/examples/tokens_with_substring_relation_rbac.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,5 @@ | ||
p, admin, tenant1, data1, read | ||
p, admin, tenant2, data2, read | ||
|
||
g, alice, admin, tenant1 | ||
g, alice, user, tenant2 |
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