Giter Club home page Giter Club logo

Comments (4)

hsluoyz avatar hsluoyz commented on May 23, 2024

可以的,定义请求:

r = sub, obj, act

其中obj表示资源类型,可以为id,name,pass,wechat
act就是GET或者PUT

策略规则就可以这样写:

p, user, wechat, PUT, allow
p, user, pass, GET, deny

然后模型参考deny-override: https://github.com/casbin/casbin#examples

from casbin.

bugstark avatar bugstark commented on May 23, 2024

我想在RESTful模式下新增一个类型就像字段的白名单
policy表现为:
p admin /api/articles GET (id)|(name)|(wechat)
请问这种方案能实现吗?

from casbin.

hsluoyz avatar hsluoyz commented on May 23, 2024

可以修改r和p来增加新的字段,比如:

r = sub, obj, act, type

然后Enforce()函数把"id"或者"name"或者"wechat"传入进去
策略定义就是:

p = sub, obj, act, type

看到你使用了类似正则的匹配:(id)|(name)|(wechat)
所以matcher可以这样写:

m = regexMatch(r.type, p.type)

from casbin.

bugstark avatar bugstark commented on May 23, 2024

非常感谢解答,我尝试一下,再次感谢开源此优秀项目

from 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.