xBoo opened a new issue, #11342:
URL: https://github.com/apache/apisix/issues/11342
### Description
i got tenantid in jwt token, and i want to use this id to route the cluster,
how can i do it ?
``` code
local jwt_obj = jwt:verify(conf.jwt_secret, token)
if jwt_obj.valid and jwt_obj.verified then
local tid = jwt_obj.payload.tid
if tid ~= nil then
local red, err = redis.new(conf)
if not red then
return 502, err
end
local domain, redis_err = red:get("tid-" .. tid)
if not domain or domain == nil or (type(domain) == "userdata"
and tostring(domain) == "userdata: NULL") then
return 502, redis_err
else
-- Here I do not know.
core.request.set_header(ctx, "x-cluster", domain)
end
else
-- todo: add no token handle
core.log.warn("tid is nil, set default cluster")
end
else
core.log.warn("jwt valid error:" .. core.json.encode(jwt_obj))
return 502, jwt_obj.reason
end
```
### Environment
- APISIX version (run `3.9.0`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -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`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]