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   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   51 人在线   最高记录 51   ·     选择语言  ·     选择编辑器
创意工作者们的社区
World is powered by code
VERSION: c3b0ae8 · 7ms · UTC 07:38 · PVG 15:38 · LAX 00:38 · JFK 03:38
♥ Do have faith in what you're doing.