node-casbin
node-casbin copied to clipboard
Are there keywords in expression parsing?
full example code
https://github.com/issuebox/casbin-jsep
policy.csv
p, alice, read
p, bob, write
normal instance
model1.conf
[request_definition]
r = sub_data, act
[policy_definition]
p = sub, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub_data.attrs.username == p.sub && r.act == p.act
const e1 = await newEnforcer(
join(__dirname, "./model1.conf"),
join(__dirname, "./policy.csv")
);
const result = await e1.enforce(
{
attrs: {
id: "alice",
},
},
"read"
);
// result === true
theresult is true,which is as expected!
exception instance
model2.confonly replacesattrsin the last line ofmodel1.confwithattr, everything else remains the same
model2.conf
[request_definition]
r = sub_data, act
[policy_definition]
p = sub, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub_data.attr.username == p.sub && r.act == p.act
const e2 = await newEnforcer(
join(__dirname, "./model2.conf"),
join(__dirname, "./policy.csv")
);
const result = await e2.enforce(
{
attr: {
id: "alice",
},
},
"read"
);
// result === false
Running the program, the
resultobtained isfalse, which is not as expected
question
In the above two examples, only one letter is different, which leads to different results. After testing, there is also a user will cause the same problem, ask: user and attr are keywords? If yes, what other keywords?
@nodece @Zxilly @Shivansh-yadav13
@vaseala plz change all texts to English
@vaseala there is no conflict like keywords, but found a bug which is causing this whenever a word ends with r or p like you said attr and user. Thanx for raising the issue
:tada: This issue has been resolved in version 5.19.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: