Casbin = way to authorization
A place for Casbin developers and users
现在注册
已注册用户请  登录
主题样式选择
默认主题样式 ✅
知乎主题样式 
hsluoyz
hsluoyz

Hi @cjea, sorry for the late response.

Using a regex match seems a bit suspicious to me. Does the regex grow for every user that Alice blocks? ^(Bob|Charlie|...). Is it a performance concern?

I think your regex way is not bad. There are also some other alternatives:

  1. Define a custom function like isBlockingUser(userA, userB), so you can define your own logic inside it and use it in the matcher or policy (with eval()).

  2. Use the deny-override model, define each blocked user as a policy, like:

p, alice, *, send, bob, deny

And if regex is the correct way to go, it feels a bit clumsy because the "recipient" field only applies to the "send" action, and not "save".

You can use keyMatch() or regexMatch() to wrap two actions into one: send|save

关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   50 人在线   最高记录 50   ·     选择语言  ·     选择编辑器
创意工作者们的社区
World is powered by code
VERSION: 6f2aea9 · 15ms · UTC 12:30 · PVG 20:30 · LAX 05:30 · JFK 08:30
♥ Do have faith in what you're doing.