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

How do I create inheritance roles in a domain RBAC policy?

  •  
  •  
    Fromate · 3年前 · 106 次点击 
    这是一个创建于 1134 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Hi everybody,

    I have the issue that I want to create simple Casbin rules sets for thousands of users and systems. I have different user roles, viewer and admin. The higher levels shall include (inherit) the lower level permissions.

    Model

    [request_definition]

    r = sub, dom, obj, act

    [policy_definition]

    p = priority, sub, dom, obj, act, eft

    [role_definition]

    g = _, _, _

    g2 = _, _

    g3 = _, _

    [policy_effect]

    e = priority(p.eft) || deny

    [matchers]

    m = g(r.sub, p.sub, r.dom) && (g2(r.sub, p.sub)) && (r.dom == p.dom || p.dom == '*') && (g3(r.obj, p.obj)) && r.act == p.act

    Policy

    g, acc1, viewer, sys1

    g, acc1, admin, sys2

    g2, admin, viewer

    g3, data1, readonly

    g3, data2, readonly

    g3, data3, readwrite

    p, 5, viewer, *, readonly, read, allow

    p, 5, viewer, *, readwrite, read, allow

    p, 5, admin, *, readwrite, write, allow

    Request

    acc1, sys1, data1, read // expected to be true, but returns false

    acc1, sys2, data1, read // expected to be true, but returns false

    When I remove the g2 part from the matcher, the idea starts to work. But I have to duplicate either a p or a g policy, so I cannot inherit the user roles any longer:

    • g, acc1, viewer, sys2
    • p, 5, admin, *, readonly, read, allow

    What am I doing wrong?

    Regards, Fromate

    106 次点击  ∙  0 人收藏  
      Tweet Weibo 忽略主题 
    1 条回复   2022-01-15 09:22:19 +08:00
    hsluoyz
    hsluoyz3年前

    please ask in github

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