SkyLothar / lua-resty-jwt

JWT For The Great Openresty
Apache License 2.0
513 stars 178 forks source link

Validation example throws exception due to validate function 3rd argument being a number and not object/table #70

Open AlexeyAtIgloo opened 7 years ago

AlexeyAtIgloo commented 7 years ago

Been playing around with guard examples and noticed the following:

Getting this exception:

2017/09/12 13:26:07 [error] 7#7: *5 lua entry thread aborted: runtime error: /usr/local/openresty/site/lualib/resty/jwt.lua:696: bad argument #1 to 'pairs' (table expected, got number)
stack traceback:
coroutine 0:
    [C]: in function 'pairs'
    /usr/local/openresty/site/lualib/resty/jwt.lua:696: in function 'validate_claims'
    /usr/local/openresty/site/lualib/resty/jwt.lua:728: in function 'verify'
    /usr/local/openresty/nginx/conf/lua/jwtguard.lua:13: in function </usr/local/openresty/nginx/conf/lua/jwtguard.lua:1>, client: ..., server: localhost, request: "GET /test/ HTTP/1.1", host: "..."

My token does not have any claim and seems like 3rd argument on below line causing this issue: here

If 3rd argument removed, everything seems to work as expected.

Thanks for a great library!