apisix
apisix copied to clipboard
bug: after enable jwt-auth plugin, route' uri cannot be set to "/*"
Issue description
enabled the jwt-auth plugin, if create a route which uri is /*, when get the jwt's token will return 401, but the other uri don't have this problem.
$curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uri": "/*",
"plugins": {
"jwt-auth": {}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:9797": 1
}
}
}'
get token
$curl http://127.0.0.1:9080/apisix/plugin/jwt/sign?key=user-key -i
HTTP/1.1 401 Unauthorized
... ...
{"message":"Missing JWT token in request"}
Environment
- apisix version (cmd:
apisix version): mater - OS:
nice report, thx for your report
https://github.com/apache/apisix/blob/master/apisix/init.lua#L377-L380
local user_defined_route_matched = router.router_http.match(api_ctx)
if not user_defined_route_matched then
router.api.match(api_ctx)
end
change to this, it might work ^_^
local user_defined_route_matched = router.api.match(api_ctx)
if not user_defined_route_matched then
router.router_http.match(api_ctx)
end