Giter Club home page Giter Club logo

Comments (2)

wenjianzhang avatar wenjianzhang commented on May 21, 2024
  • jwt只是验证用户是否有权访问
  • casbin是验证有权限的角色能够访问哪些资源

casbin 在项目中的使用:

首先需要制定自己的策略配置,什么是策略配置呢?

例如:

p,common,/api/v1/menulist,GET

这就是一组用户角色映射关系

common 角色能够访问资源 /api/v1/menulistGET 方式。

规则:

[policy_definition]
p = sub, obj, act

[matchers]

m = r.sub == p.sub && (keyMatch2(r.obj, p.obj) || keyMatch(r.obj, p.obj)) && (r.act == p.act || p.act == "*")

p = sub, obj, act >> p,common,/api/v1/menulist,GET

keyMatch2(r.obj, p.obj) || keyMatch(r.obj, p.obj) 资源匹配规则内置提供的有一些匹配函数,因为我们项目中使用到了path参数,所以这里做了两种匹配的或计算。

以上内容是配置文件规则的简单说明,在程序里边只不过是按照上述规则进行动态的计算罢了。

另外就是使用顺序,JWT 在前,Casbin在后,这个知道为什么吗?如果想知道请留言吧。

from go-admin.

W-Jie avatar W-Jie commented on May 21, 2024

另外就是使用顺序,JWT 在前,Casbin在后,这个知道为什么吗?如果想知道请留言吧。

想知道,望解答,谢谢

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