casbin

CASBIN url subset block


I have following policies:

p, alice, /alice_data/:id/using, GET
p, bob, /alice_data/*, GET

My current enforcer enforcement result:

alice, /alice_data/hello, GET  ->  True
bob, /alice_data/123/using, GET -> True

I need to block bob for /alice_data/:id/using

alice, /alice_data/hello, GET  ->  i want it to be True
bob, /alice_data/123/using, GET -> i want it to be **False**

since /alice_data/123/using is a subset of /alice_data/* , but i want to block bob for /alice_data/123/using, can I do that ?? please guide


Solution

  • To control whether /alice_data/123/using matches /alice_data/*, you need to use regexMatch or define your own keyMatch: https://casbin.org/docs/en/function