Getting "bad argument #2 to 'ngx_lua_ffi_exit' (cannot convert 'nil' to 'int')" error
Hi Team,
I am trying to setup a configuration to deny with 401 Http Response for Backend-API calls from Frontend in case the token session has expired.. I am using the below environment and OpenResty latest version. However i am not sure why i get the below error. Could you please guide me as to what should be correct library to be used? Please let me know if you need any further information.
Environment
- lua-resty-openidc version 1.7.5
- OpenID Connect provider: Mercedes-Benz
- openresty/1.21.4.1
Expected behaviour
To return a 401 Response
Actual behaviour
getting an error
Minimized example
Minimal, complete configuration that reproduces the behavior.
Configuration and NGINX server log files
Config and logs for the minimized example, possibly provided as attachments.
Open-Resty Config:
local res, err if string.find(ngx.var.request_uri, '/api/') then res, err = require("resty.openidc").authenticate(opts, nil, "deny") if err then ngx.status = 401 ngx.say(err) ngx.log(ngx.ERR, "authentication failed") ngx.log(ngx.ERR, err) ngx.exit(ngx.NGX_HTTP_UNAUTHORIZED) end else res, err = require("resty.openidc").authenticate(opts)
Error Log
2022/10/11 04:58:26 [error] 1231938#1231938: *6673 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/core/exit.lua:52: bad argument #2 to 'ngx_lua_ffi_exit' (cannot convert 'nil' to 'int') stack traceback: coroutine 0: [C]: in function 'ngx_lua_ffi_exit' /usr/local/openresty/lualib/resty/core/exit.lua:52: in function 'exit' access_by_lua(nginx.conf:112):22: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /api/4.0/edges HTTP/1.0", host: "localhost:8080" 2022/10/11 04:58:26 [error] 1231938#1231938: *6673 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/core/exit.lua:52: bad argument #2 to 'ngx_lua_ffi_exit' (cannot convert 'nil' to 'int') stack traceback: coroutine 0: [C]: in function 'ngx_lua_ffi_exit' /usr/local/openresty/lualib/resty/core/exit.lua:52: in function 'exit' access_by_lua(nginx.conf:112):22: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /api/4.0/edges HTTP/1.0", host: "localhost:8080" 2022/10/11 04:58:26 [error] 1231938#1231938: *6673 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/core/exit.lua:52: bad argument #2 to 'ngx_lua_ffi_exit' (cannot convert 'nil' to 'int') stack traceback: coroutine 0: [C]: in function 'ngx_lua_ffi_exit' /usr/local/openresty/lualib/resty/core/exit.lua:52: in function 'exit' access_by_lua(nginx.conf:112):22: in main chunk, client: 127.0.0.1, server: localhost, request: "GET /api/4.0/edges HTTP/1.0", host: "localhost:8080"