apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.35k stars 2.49k forks source link

help request: missing user key in JWT token #11365

Open bakuppus opened 3 months ago

bakuppus commented 3 months ago

Description

Our existing JWT token payload not contains key, due to we are getting error "missing user key in JWT token". Here Apache APISIX expects a specific key in the JWT payload, which is not present in our existing token.

Does Apache APISIX's jwt-auth plugin must requires the key value defined in the consumer ?

How to resolve this issue without modifying our existing token payload ?

bala@kubelancer ~ % curl -s -i -X GET "httpbin1.poc.kubelancer.net/get?foo1=bar1&foo2=bar2" -H "Authorization: Bearer ${TOKEN}"HTTP/1.1 401 UnauthorizedDate: Tue, 18 Jun 2024 12:54:08 GMTContent-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: APISIX/3.9.1

{"message":"missing user key in JWT token"}
bala@kubelancer ~ %

Environment

hanqingwu commented 3 months ago

Yes , key is required https://apisix.apache.org/docs/apisix/plugins/jwt-auth/

TheShubhendra commented 2 months ago

I am also getting the same issue. Our jwt tokens has sub as a key for user_id. Where can i set this key when enabling jwt-auth plugin for routes.