首页   API文档   注册   登录
Casbin = way to authorization
A place for Casbin developers and users
现在注册
已注册用户请  登录
lantu-group
Casnode  ›  Casbin

Node-Casbin bug

  •  
  •  
    lantu-group · 2个月前 · 42 次点击 
    这是一个创建于 73 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我用两个 in 操作 && 串联起来,如果是 true && true , 实际得到的结果是 false, 这个是什么问题呀?

    将 多个 in 拆成单独的 matchers 是正常的,&& 起来就非预期了.

    const fs = require ('fs') const path = require ('path') const Casbin = require ('casbin')

    const model1Text = `request_definition r = sub, obj, act

    policy_definition p = sub, obj, act

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

    matchers m = r.act in "('In', 'Out')"`

    const model2Text = `request_definition r = sub, obj, act

    policy_definition p = sub, obj, act

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

    matchers m = r.sub in "('root', 'guest')"`

    const model3Text = `request_definition r = sub, obj, act

    policy_definition p = sub, obj, act

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

    matchers m = r.act in "('In', 'Out')" && r.sub in "('root', 'guest')"` ; (async () => { //initial models const path1 = path.resolve (dirname, './model1.conf') const path2 = path.resolve (dirname, './model2.conf') const path3 = path.resolve (__dirname, './model3.conf') fs.writeFileSync (path1, model1Text) fs.writeFileSync (path2, model2Text) fs.writeFileSync (path3, model3Text)

    //loading enforcer const enforcer1 = await Casbin.newEnforcer (path1) const enforcer2 = await Casbin.newEnforcer (path2) const enforcer3 = await Casbin.newEnforcer (path3)

    //test const result1 = await enforcer1.enforce ('root', {}, 'In') const result2 = await enforcer2.enforce ('root', {}, 'In') const result3 = await enforcer3.enforce ('root', {}, 'In') console.log ('result1 : ', result1) //true console.log ('result2 : ', result2) //true console.log ('result3 : ', result3) //false })();

    42 次点击  ∙  0 人收藏  
    Tweet Weibo 忽略主题 
    目前尚无回复
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   0 人在线   最高记录 30   ·     选择语言  ·     选择编辑器
    创意工作者们的社区
    World is powered by code
    VERSION: b315f58 · 21ms · UTC 20:55 · PVG 04:55 · LAX 13:55 · JFK 16:55
    ♥ Do have faith in what you're doing.