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

keyGet2 always returns *matcher result should be boolean or number* #332

Closed
tomfriedhof opened this issue Nov 17, 2021 · 5 comments · Fixed by #347
Closed

keyGet2 always returns *matcher result should be boolean or number* #332

tomfriedhof opened this issue Nov 17, 2021 · 5 comments · Fixed by #347
Assignees
Labels
bug Something isn't working

Comments

@tomfriedhof
Copy link

I have confirmed that the operator does in fact return the correct value. However, it is not making back from the coreEnforcer. This is what my stack trace looks like when running this:

      matcher result should be boolean or number

      at Enforcer.privateEnforce (/app/node_modules/casbin/lib/cjs/coreEnforcer.js:391:31)
      at privateEnforce.next (<anonymous>)
      at Object.generatorRunAsync (/app/node_modules/casbin/lib/cjs/util/util.js:154:41)
      at async testEnforce (/app/test/casbin/user.test.ts:34:20)
      at async /app/test/casbin/user.test.ts:25:9

I am running enforce with the following params:

const params = {
        sub: "role::sales",
        input: { sub, obj },
        obj: '/user/123',
        act: "ListUsers",
      };
await e.enforce(params.input, params.sub, params.obj, params.act);

Here is what the matcher looks like:

[matchers]
m = g(r.sub, p.sub) && keyGet2(r.obj, p.obj, 'role')

and policy:

p, /user/:role, role::sales, ListUsers
@casbin-bot
Copy link
Member

@casbin-bot casbin-bot added the question Further information is requested label Nov 17, 2021
@hsluoyz hsluoyz added bug Something isn't working and removed question Further information is requested labels Nov 25, 2021
@hsluoyz
Copy link
Member

hsluoyz commented Nov 25, 2021

Hi @tomfriedhof sorry for late response. Can you make a PR to fix it?

@hsluoyz
Copy link
Member

hsluoyz commented Jan 20, 2022

@fabian4

@hsluoyz
Copy link
Member

hsluoyz commented Jan 22, 2022

@Shivansh-yadav13

@nodece
Copy link
Member

nodece commented Mar 1, 2022

You pass incorrect params to enforce:

const params = {
        sub: "role::sales",
        input: { sub, obj },
        obj: '/user/123',
        act: "ListUsers",
      };
await e.enforce(params.input.sub, params.input.obj, params.sub, params.obj, params.act);

@hsluoyz hsluoyz removed this from Node-Casbin Easy Tasks in Casbin Easy Tasks for Beginners/Student Applicants Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants