Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: jwt-auth 500 error with not HS256 algorithm #2325

Closed
tanjiancheng opened this issue Sep 26, 2020 · 4 comments · Fixed by #2356
Closed

bug: jwt-auth 500 error with not HS256 algorithm #2325

tanjiancheng opened this issue Sep 26, 2020 · 4 comments · Fixed by #2356
Assignees

Comments

@tanjiancheng
Copy link

Issue description

call curl http://127.0.0.1:9080/apisix/plugin/jwt/sign?key=user-key -i
and then 500 Internal Server Error

Environment

  • apisix version (cmd: apisix version): both 1.2 and 1.5
  • OS: linux

Minimal test code / Steps to reproduce the issue

curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "username": "jack",
    "plugins": {
        "jwt-auth": {
            "key": "user-key",
            "algorithm": "HS384",
            "secret": "my-secret-key"
        }
    }
}'

result:

{"node":{"value":{"username":"jack","plugins":{"jwt-auth":{"algorithm":"HS384","key":"user-key","secret":"my-secret-key","exp":86400}}},"createdIndex":50,"key":"\/apisix\/consumers\/jack","modifiedIndex":50},"prevNode":{"value":"{\"username\":\"jack\",\"plugins\":{\"jwt-auth\":{\"algorithm\":\"HS256\",\"secret\":\"my-secret-key\",\"key\":\"user-key\",\"exp\":86400}}}","createdIndex":49,"key":"\/apisix\/consumers\/jack","modifiedIndex":49},"action":"set"}

curl http://127.0.0.1:9080/apisix/plugin/jwt/sign?key=user-key -i

result:

HTTP/1.1 500 Internal Server Error
Date: Sat, 26 Sep 2020 03:17:13 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 174
Connection: close
Server: APISIX web server

<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>openresty</center>
</body>
</html>

check apisix error.log

2020/09/26 03:23:41 [error] 48#48: *11759 lua entry thread aborted: runtime error: unknown reason
stack traceback:
coroutine 0:
        [C]: in function 'error'
        /usr/local/apisix//deps/share/lua/5.1/resty/jwt.lua:505: in function 'sign'
        /usr/local/apisix/apisix/plugins/jwt-auth.lua:206: in function 'handler'
        /usr/local/apisix/apisix/plugin.lua:209: in function 'handler'
        /usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:739: in function 'dispatch'
        /usr/local/apisix/apisix/http/router/radixtree_uri.lua:110: in function 'match'
        /usr/local/apisix/apisix/init.lua:336: in function 'http_access_phase'
        access_by_lua(nginx.conf:167):2: in main chunk, client: 172.18.0.1, server: , request: "GET /apisix/plugin/jwt/sign?key=user-key HTTP/1.1", host: "127.0.0.1:9080"

is this a bug?I use https://github.com/apache/apisix-docker/example to make the test env

@tanjiancheng
Copy link
Author

nobody answer about this?

@moonming
Copy link
Member

moonming commented Oct 4, 2020

sorry for late reply
I will finger it out today

@moonming
Copy link
Member

moonming commented Oct 4, 2020

Reproduce in the mster branch, I am diging

@moonming
Copy link
Member

moonming commented Oct 4, 2020

https://github.com/SkyLothar/lua-resty-jwt/blob/master/lib/resty/jwt.lua#L505
lua-resty-jwt not support HS384 now, it's a bug of APISIX.
I will fix it later. thanks for your report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants