Slade66 commented on issue #12658:
URL: https://github.com/apache/apisix/issues/12658#issuecomment-3393056061
Hello @Baoyuantop @hanqingwu, thank you for your responses.
I’ve resolved the issue. The `store_in_ctx` configuration of jwt-auth stores
the JWT payload in memory. I then used the following configuration:
```json
"plugins": {
"jwt-auth": {
"store_in_ctx": true
},
"serverless-post-function": {
"phase": "rewrite",
"functions": [
"return function(conf, ctx) local p = ctx.jwt_auth_payload; if not p
then return end; if p.username then ngx.req.set_header('X-User-Name',
tostring(p.username)) end; if p.sub then ngx.req.set_header('X-User-Sub',
tostring(p.sub)) end; end"
]
}
}
```
This solved the problem. By using the serverless plugin with a Lua script, I
can extract claims from the JWT instead of using the proxy-rewrite plugin.
If you want to extract JWT claims and pass them to your backend service, you
can use jwt-auth together with the serverless plugin.
--
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]