Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

I found something strange, here is my model (I stripped all the fluff):

[request_definition]
r = user, path, method, tag

[policy_definition]
p = role, path, method, tag

[policy_effect]
e = some(where (p.eft == allow))

[role_definition]
g = _, _, _

[matchers]
m = g(r.user, p.role, r.tag)

Using the following policy:

p, 1, /something, GET, sol-*
g, 2, 1, sol-1
g, 3, 1, sol-1

And my request:

1, /something, GET, sol-1

I get true even though I expect it to be false

If I change my policy:

p, r1, /something, GET, sol-*
g, 2, r1, sol-1
g, 3, r1, sol-1

Then in results into false as it should

Why is this the case?

Is it best practice to prefix ids if those are used in the policy?

You can test it in the editor

1views
2users
1 minread

Finally:

p, 1, /something, GET, sol-*

Why if there are zero groups does it pass. There should be nothing to match right?
But if I do:

p, r1, /something, GET, sol-*

It again gives false as it should be

1 / 3
May 2024