orange icon indicating copy to clipboard operation
orange copied to clipboard

Jwt Auth attempt to index field 'ALGOS' (a nil value)

Open liulei18 opened this issue 5 years ago • 3 comments

Version

v0.7.0

Plugin

Jwt Auth

Configuration
  • nginx.conf
        location = /sign {
            content_by_lua '
                local cjson = require "cjson"
                local jwt = require "resty.jwt"

                local jwt_token = jwt:sign(
                    "lua-resty-jwt",
                    {
                        header={typ="JWT", alg="HS256"},
                        payload={foo="bar"}
                    }
                )
               ngx.say(jwt_token)
            ';
        }
Execute
  • curl 'http://ip:port/sign'
Error Log
./lualib/resty/jwt.lua: in function 'sign'
        content_by_lua(orange.conf:571):5: in function <content_by_lua(orange.conf:571):1>, client: 192.168.252.201, server: orange.com, request: "GET /sign HTTP/1.1", host: "orange.com"
2019/07/12 17:59:26 [error] 244211#0: *14 lua entry thread aborted: runtime error: ./lualib/resty/jwt.lua:494: attempt to index field 'ALGOS' (a nil value)
Solution

I install third-party packages as required according to README.md like this

#opm --install-dir=./ get zhangbao0325/orangelib      //opm download the 3rd packages

According to the error log, i find the reason. according to above order installs package has a problem in lualib/resty/hmac.lua,then i change hmac.lua to https://github.com/jkeys089/lua-resty-hmac/blob/master/lib/resty/hmac.lua. it is ok. Hope to repackage orangelib. @zhangbao0325

liulei18 avatar Jul 15 '19 07:07 liulei18

Version

v0.7.0

Plugin

Jwt Auth

Configuration
  • nginx.conf
        location = /sign {
            content_by_lua '
                local cjson = require "cjson"
                local jwt = require "resty.jwt"

                local jwt_token = jwt:sign(
                    "lua-resty-jwt",
                    {
                        header={typ="JWT", alg="HS256"},
                        payload={foo="bar"}
                    }
                )
               ngx.say(jwt_token)
            ';
        }
Execute
  • curl 'http://ip:port/sign'
Error Log
./lualib/resty/jwt.lua: in function 'sign'
        content_by_lua(orange.conf:571):5: in function <content_by_lua(orange.conf:571):1>, client: 192.168.252.201, server: orange.com, request: "GET /sign HTTP/1.1", host: "orange.com"
2019/07/12 17:59:26 [error] 244211#0: *14 lua entry thread aborted: runtime error: ./lualib/resty/jwt.lua:494: attempt to index field 'ALGOS' (a nil value)
Solution

I install third-party packages as required according to README.md like this

#opm --install-dir=./ get zhangbao0325/orangelib      //opm download the 3rd packages

According to the error log, i find the reason. according to above order installs package has a problem in lualib/resty/hmac.lua,then i change hmac.lua to https://github.com/jkeys089/lua-resty-hmac/blob/master/lib/resty/hmac.lua. it is ok. Hope to repackage orangelib. @zhangbao0325

Thank for your issue and suggestion! I will confirm this problem and update the packages as soon as possible.

zhangbao0325 avatar Jul 15 '19 07:07 zhangbao0325

I have confirmed this issue and found that the 3rd package of hmac.lua has updated on July 2nd , I have already updated zhangbao0325/orangelib. Thank you for your suggestion again!

zhangbao0325 avatar Jul 16 '19 13:07 zhangbao0325

I have confirmed this issue and found that the 3rd package of hmac.lua has updated on July 2nd , I have already updated zhangbao0325/orangelib. Thank you for your suggestion again!

Another issue(https://github.com/orlabs/orange/issues/281) is simile to this . please confirm! I am waiting in a hurry. Your support is greatly appreciated.

liulei18 avatar Jul 16 '19 15:07 liulei18