地产平面网站,中国安能建设集团有网站,麻章手机网站建设,iis5.1怎么发布网站目录 1、apisix的auth-casbin官方介绍
2、casbin介绍和使用
2.1基本知识#xff1a;
2.2使用例子
3、配置插件
4、postman调用
5、auth-casbin的坑 1、apisix的auth-casbin官方介绍
authz-casbin | Apache APISIX -- Cloud-Native API Gateway
2、casbin介绍和使用
c…目录 1、apisix的auth-casbin官方介绍
2、casbin介绍和使用
2.1基本知识
2.2使用例子
3、配置插件
4、postman调用
5、auth-casbin的坑 1、apisix的auth-casbin官方介绍
authz-casbin | Apache APISIX® -- Cloud-Native API Gateway
2、casbin介绍和使用
casbin如果看不懂可以学习基础语法
需要学习casbin的详细理解过程附图片理解rbac模型-CSDN博客
2.1基本知识
r sub, obj, act
意思请求入参实体资源方法
p sub, obj, act
意思策略实体资源方法
g _ , _
意思角色权限这里的意思是g收到两个参数 g 用户角色
2.2使用例子
policy: p,GRANT_ROLE_firstconsumer,/dcpyo/test, *\ng,firstconsumer,GRANT_ROLE_firstconsumer\np,GRANT_ROLE_11120150115,/dcpyo/test, *\ng,11120150115,GRANT_ROLE_11120150115\n,
username: appKey
policy的意思是
p,GRANT_ROLE_firstconsumer,/dcpyo/test, *
意思策略GRANT_ROLE_firstconsumer有接口/dcpyo/test的所有权限
g,firstconsumer,GRANT_ROLE_firstconsumer
意思用户firstconsumer有权限GRANT_ROLE_firstconsumer
3、配置插件
auth-caszbin username可以指定头的别名
配置一个路由例子
{
uri: /dcpyo/test,
name: 4种认证20250113,
desc: 4种认证20250113,
plugins: {
authz-casbin: {
model: [request_definition] \n r sub, obj, act \n [policy_definition] \n p sub, obj, act \n [role_definition] \n g _, _ \n [policy_effect] \n e some(where (p.eft allow)) \n [matchers] \n m (g(r.sub, p.sub) || keyMatch(r.sub, p.sub)) keyMatch(r.obj, p.obj) keyMatch(r.act, p.act) ,
policy: p,GRANT_ROLE_firstconsumer,/dcpyo/test, *\ng,firstconsumer,GRANT_ROLE_firstconsumer\np,GRANT_ROLE_11120150115,/dcpyo/test, *\ng,11120150115,GRANT_ROLE_11120150115\n,
username: appKey
},
proxy-rewrite: {
uri: /dapi/v1.0/ssApi/getDataForGet,
use_real_request_uri_unsafe: false
}
},
upstream: {
nodes: [
{
host: 10.255.159.236,
port: 9034,
weight: 1
}
],
type: roundrobin,
hash_on: vars,
scheme: http,
pass_host: pass
},
status: 1
}
4、postman调用
调用的时候请求头就用appKey上面设置的别名 5、auth-casbin的坑
auth-casbin如果多个路由配置的userName时一样的值会导致路由1可能用到路由2的策略这是因为默认情况下auth-casbin会缓存策略。
conf是全局配置这里就是隐式的使用了缓存