add_named_matching_func not fully functional in 1.2.0
See original GitHub issueHi, there is some change applied in 1.2.0 which is preventing the following code and rules to run as they were in 1.1.3 The policy was working fine in 1.1.3. I believe it has something to do with “g2”, add_named_matching_func and fm functions
code:
enforcer = casbin.Enforcer("./rbac.conf", "./policy.csv")
enforcer.add_named_matching_func("g2", enforcer.fm.fm["globMatch"])
rbac.conf:
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, role
[role_definition]
g = _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g2(r.act, p.role) && (g(r.sub, p.sub) || p.sub=='*') && keyMatch(r.obj, p.obj)
policy.csv
p, root, *, owner
g, root@localhost, root
g2, *.*, owner
expected:
root@localhost, /, org.create
-> PASS (get a FAIL in 1.2.0)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:10 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have located the problem. It was because role manager will use the first gRule hit by matching_func to judge the link between the roles. In this example, it’s
*.create
andorg.create
, it hit ruleg2, *.update, admin
,admin
is notowner
and g2() return false immediately. I will later fix this.@Zxilly you can add to the unittests . Many thanks for locating the problem!