Giter VIP home page Giter VIP logo

Comments (2)

hsluoyz avatar hsluoyz commented on May 17, 2024

@hequan2017 , 代码里初始化Casbin Enforcer的时候,确实没有指定Adapter,也就不会加载任何策略、数据库表。他是把逻辑写在model里了:https://github.com/LyricTian/gin-admin/blob/master/config/model.conf

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) == true \
    && keyMatch2(r.obj, p.obj) == true \
    && regexMatch(r.act, p.act) == true \
    || r.sub == "root" \
    || keyMatch2(r.obj, "/api/v1/login") == true \
    || keyMatch2(r.obj, "/api/v1/logout") == true \
    || keyMatch2(r.obj, "/api/v1/current/menus") == true \
    || keyMatch2(r.obj, "/api/v1/current/user") == true

所以实现了和Adapter类似的效果,不过按道理说,/api/v1/login 这些具体RESTful路径,应该是放到policy(csv文件、数据库)里的

from gin-admin.

hequan2017 avatar hequan2017 commented on May 17, 2024

了解了。感谢作者。 期待后续功能。

from gin-admin.

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.