Giter Site home page Giter Site logo

Comments (9)

nodece avatar nodece commented on May 12, 2024

YES. It is match all policy.

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

Hi @Jarvie8176 , node-casbin internally uses expression-eval to evaluate the matcher. Probably it doesn't support short-circuit. If you want this feature, you can ask this in their repo's issues.

from node-casbin.

Jarvie8176 avatar Jarvie8176 commented on May 12, 2024

Hi @Jarvie8176 , node-casbin internally uses expression-eval to evaluate the matcher. Probably it doesn't support short-circuit. If you want this feature, you can ask this in their repo's issues.

Do you mean keyMatch() should match all policies in this case?

from node-casbin.

nodece avatar nodece commented on May 12, 2024

Casbin need call policy_effect determines the return value after match all polices.

from node-casbin.

Jarvie8176 avatar Jarvie8176 commented on May 12, 2024

The test would pass if I used regexMatch() instead of keyMatch(). I think my question is what should keyMatch("alice:res1:A", "alice:*:B") return?

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

Hi @Jarvie8176 , keyMatch("alice:res1:A", "alice:*:B") should return false. See:

https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L25-L37

from node-casbin.

Jarvie8176 avatar Jarvie8176 commented on May 12, 2024

I wrote a failing test here: Jarvie8176@d66e4a1

It looks like keyMatch()'s precondition is that the wildcard, if exists, should be the last character in key2 but that is not satisfied in this case. To match wildcard properly you may have to implement a DP algorithm. Would you consider using utility libraries (e.g. matcher or minimatch) to offload complexity?

from node-casbin.

nodece avatar nodece commented on May 12, 2024

@Jarvie8176 Looking good, our team needs to discuss.

from node-casbin.

hsluoyz avatar hsluoyz commented on May 12, 2024

@Jarvie8176 keyMatch() assumes that * is the last character of the string. It is not designed to handle cases like alice:*:B. Please use regexMatch() for your scenario. You can add your own custom function to Casbin too.

from node-casbin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.