cdbattags / lua-resty-jwt

JWT For The Great Openresty
Apache License 2.0
146 stars 44 forks source link

Manual install steps #50

Open kminder opened 3 years ago

kminder commented 3 years ago

I'm trying to add lua-resty-jwt to Kubernetes ingress-nginx. In their recent versions they have stopped using luarocks and are installing Lua modules manually. See https://github.com/kubernetes/ingress-nginx/blob/master/images/nginx/rootfs/build.sh#L597 I've tried installing both lua-resty-jwt and lua-resty-hmac as shown below but it isn't working.

export LUA_RESTY_JWT_VERSION=0.2.3
export LUA_RESTY_HMAC_VERSION=0.05

get_src 35ae361abfdc1b7039df9ef9d0e0fe2b8a6e6e381ef99addde186f5fed6b2023 \
        "https://github.com/cdbattags/lua-resty-jwt/archive/refs/tags/v$LUA_RESTY_JWT_VERSION.tar.gz"

get_src a8bb37a5d272545d57fbd1a78be54cca5b96d6c1048e396b137bdacab575fc6a \
        "https://github.com/jkeys089/lua-resty-hmac/archive/refs/tags/v$LUA_RESTY_HMAC_VERSION.tar.gz"

cd "$BUILD_PATH/lua-resty-hmac-$LUA_RESTY_HMAC_VERSION"
make install

cd "$BUILD_PATH/lua-resty-jwt-$LUA_RESTY_JWT_VERSION"
install -d /usr/local/lib/lua/resty
install lib/resty/*.lua /usr/local/lib/lua/resty

When the /etc/nginx/conf.lua lines below execute...

local jwt = require "resty.jwt"
local jwt_obj = jwt:load_jwt(token)

I get this error...

2021/05/06 22:42:09 [error] 22#22: *40 lua entry thread aborted: runtime error: /etc/nginx/conf.lua:77: attempt to index local 'jwt' (a number value)

So are there any suggested instructions for installing lua-resty-jwt manually without luarocks?

cdbattags commented 3 years ago

So I compared against https://github.com/jkeys089/lua-resty-hmac/blob/master/Makefile and it looks to be that straightforward but I can add a PR to test the make in the workflow for builds.

Relevant files:

Feel free to attempt a PR to do the same if you don't want to wait on me!

cdbattags commented 3 years ago

Do you have a link to your sample Dockerfile to test?

Maybe a minimal sample repo?

cdbattags commented 3 years ago

Are you missing the LUA_VERSION perhaps in the install -d path?

cdbattags commented 3 years ago

Ah, looks like you need the module add:

https://github.com/jkeys089/lua-resty-hmac/blob/master/Makefile#L16

kminder commented 3 years ago

Unless I'm misunderstanding, the "missing" $(INSTALL) resty_modules/lualib/resty/*.lua $(DESTDIR)$(LUA_LIB_DIR)/resty seems unlikely to be related. I note that the repo https://github.com/jkeys089/lua-resty-hmac has no such resty_modules nor does https://github.com/jkeys089/lua-resty-hmac/archive/refs/tags/v0.05.tar.gz. Furthermore none of the other lua-resty-* modules I checked included this step. For example... https://github.com/openresty/lua-resty-string/blob/master/Makefile#L12 https://github.com/ledgetech/lua-resty-http/blob/master/Makefile#L19

kminder commented 3 years ago

This may be something to unique 0.2.3. I reverted to 0.2.2 and I'm not hitting the same issue.

Joelgullander commented 1 year ago

Any chance this would be added soon?

Joelgullander commented 1 year ago

Also would like this as I am in the same situation with the ingress-nginx not supporting luarocks