node-casbin
node-casbin copied to clipboard
How to use globMatch when matching roles
Hi, I might be misunderstanding how the matcher works with the g function with roles. I'm following this example except I'm using the globMatch - https://casbin.org/docs/en/rbac-with-pattern
I'm trying to use the online editor to test my rules and setup https://casbin.org/casbin-editor/#FCWSF9J7X
My config is:
[request_definition]
r = subject, domain, object, action
[policy_definition]
p = subject, domain, object, action
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.subject, p.subject) && globMatch(r.domain, p.domain) && globMatch(r.object, p.object) && globMatch(r.action, p.action)
Policy:
# Testing with wildcard as the subject
p, foo:*:bar, domain, resource, read
# testing with wildcard as the group
p, foo2:rule:bar, domain, resource2, read
g, foo2:*:bar, foo2:rule:bar
Checks:
foo:test:bar, domain, resource, read
foo2:test:bar, domain, resource2, read
Am I using this feature incorrectly? Any help is appreciated!
@nodece @Zxilly @Shivansh-yadav13
@Shivansh-yadav13
/cc @Zxilly @nodece
Apologies -- I figured this out. I still had my matcher set to a custom matcher I was debugging with:
This is the pattern to use when you want to use a wildcard for g
# testing with wildcard as the group
p, foo2:rule:bar, domain, resource2, read
g, foo2:*:bar, foo2:rule:bar
And the test:
foo2:test:bar, domain, resource2, read