help request: Upstream services require different consumers to return different information on how to place their username in the header, and whether this header can be used as the username for casbin
Description
Upstream services require different consumers to return different information on how to place their username in the header, and whether this header can be used as the username for casbin
Environment
- APISIX version (run
apisix version): - Operating system (run
uname -a): - OpenResty / Nginx version (run
openresty -Vornginx -V): - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info): - APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run
luarocks --version):
can you provider more info about the http body ?
casbin is responsible for authorization, not authentication. maybe you should process authorization by your self by Casbin.
of course , you can set http header by the proxy-rewrite plugin.
reference: https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/
I'm not talking about authorization, but how to solve the problem of authorization and authentication at the same time
In addition, identity information is passed to the upstream through the gateway, and the upstream returns different results according to different identities in the same route
are you read this https://apisix.apache.org/zh/docs/apisix/plugins/authz-casbin/ ? maybe it's useful for you
You didn't understand what I meant
Can you give a specific example? I can't imagine your scene in one or two sentences
There are three consumers a, b, and c. A and b have the same organization as 1, and c has the same organization as 2. The authentication of a, b, and c needs to be different. When accessing the same upstream, a and b return 11, and c return 22. Upstream only returns based on the organizational judgment passed in the header, without consumer information
And abc has different permission controls for different upstream
I need to prevent a from obtaining 22 through any means
What is the execution order of the three plugins key-auth ,proxy-rewrite and authz-casbin ? How to make them execute in the order of key-auth ,proxy-rewrite and authz-casbin
`"key-auth": {}, "proxy-rewrite": { "headers": { "add": { "tenant": "$consumer_group_id" } } }, "authz-casbin": { "model": "[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) || keyMatch(r.sub, p.sub)) && keyMatch(r.obj, p.obj) && keyMatch(r.act, p.act)",
"policy": "p, *, web1, GET
p, admin, *, *
g, 1000, admin",
"username": "tenant"
}
},`
I want to use proxy rewrite to write consumer group information to the header, and then use casbin to confirm permissions. Upstream users can also obtain header information
`{ "name": "web1-rewrite", "status": 1, "methods": [ "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE", "PURGE" ], "priority": 0, "labels": {}, "uri": "/web1/*", "plugins": {
"proxy-rewrite": {
"_meta": {
"priority": 1
},
"headers": {
"set": {
"tenant": "$consumer_group_id"
}
}
},
"key-auth": {
"_meta": {
"priority": 2
}
},
"authz-casbin": {
"_meta": {
"priority": 0
},
"model": "[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) || keyMatch(r.sub, p.sub)) && keyMatch(r.obj, p.obj) && keyMatch(r.act, p.act)",
"policy": "p, *, web1, GET
p, admin, *, *
g, 2080, admin",
"username": "tenant"
}
},
"upstream_id": "452002436731634371" }`
I have 1 consumer group 2080. Jack is a consumer in 2080. I added the header as the ID of the consumer group using proxy rewrite, and verified the header using casbin. Surprisingly, the header. add implemented my idea, but the header. set failed
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.