Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

&& Error #308

Closed
lantu-group opened this issue Aug 7, 2021 · 4 comments · Fixed by #313
Closed

&& Error #308

lantu-group opened this issue Aug 7, 2021 · 4 comments · Fixed by #313
Assignees
Labels
question Further information is requested released

Comments

@lantu-group
Copy link

lantu-group commented Aug 7, 2021

I used multi in and && syntax as matchers,if conditions is true && true, got result is false, but i expect result is true, this is a bug?

The below is my test codes

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
})();
@hsluoyz
Copy link
Contributor

hsluoyz commented Aug 7, 2021

@Zxilly @Gabriel-403

@hsluoyz hsluoyz self-assigned this Aug 7, 2021
@hsluoyz hsluoyz added the question Further information is requested label Aug 7, 2021
@Zxilly
Copy link
Contributor

Zxilly commented Aug 11, 2021

@lantu-group matchers should be m = r.act in ['In', 'Out'] && r.sub in ['root', 'guest']

@lantu-group
Copy link
Author

Ref discussion: casbin/casbin#863

@github-actions
Copy link

🎉 This issue has been resolved in version 5.11.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants