zmartzone / lua-resty-openidc

OpenID Connect Relying Party and OAuth 2.0 Resource Server implementation in Lua for NGINX / OpenResty
Apache License 2.0
967 stars 247 forks source link

Entry thread aborted: runtime error: attempt to call field 'start' (a nil value) #438

Open dsantanu opened 2 years ago

dsantanu commented 2 years ago
Environment
Actual behaviour

For the info, I'm using it on our ingress-nginx-controller, with the entire content copied from /usr/local/openresty/lualib/resty to /etc/nginx/lua/. This my current code:

location ~* "^/myui(/|$)(.*)" {
  .....
  .....
  access_by_lua_block {
      local opts = {
          redirect_uri = "/redirect_uri",
          accept_none_alg = true,
          discovery = "http://keycloak.myproject.local:8080/auth/realms/master/.well-known/openid-configuration",
          client_id = "myui",
          client_secret = "ABCDEFgHIJKLMnOPQRSTuVWXYZ",
          redirect_uri_scheme = "https",
          logout_path = "/logout",
          redirect_after_logout_uri = "http://keycloak.myproject.local:8080/auth/realms/master/protocol/openid-connect/logout?redirect_uri=https://ingress.myproject.local/myui/",
          redirect_after_logout_with_id_token_hint = false,
          session_contents = {id_token=true}
      }
      -- call introspect for OAuth 2.0 Bearer Access Token validation
      local res, err = require("resty.openidc").authenticate(opts)
           if err then
             ngx.status = 403
             ngx.say(err)
             ngx.exit(ngx.HTTP_FORBIDDEN)
           end
      }

      expires       0;
      add_header    Cache-Control private;
  }
}

Upon running, I get 500 Internal Server Error on the browser, with the error msg:

[error] 549#549: *123249 lua entry thread aborted:  run time error: /etc/nginx/lua/resty/openidc.lua:1459: attempt to call field 'start' (a nil value)
stack traceback:
coroutin 0:
     /etc/nginx/lua/resty/openidc.lua: in function 'authenticate' 
     access_by_lua(nginx.conf:1075): 16: in main chunk, client xx.xx.xx.xx , server:  ingress.myproject.local, request: "GET /myui HTTP/2.0", host: "ingress.myproject.local"

I don't see anything significant in the log related to that. Any idea why I'm getting this or what am I doing wrong?

-S

bodewig commented 1 year ago

the line number of your stack trace is https://github.com/zmartzone/lua-resty-openidc/blob/v1.7.5/lib/resty/openidc.lua#L1459 in 1.7.5 which doesn't make any sense as nobody is trying to use start here. Are you sure 1.7.5 is the version you are running?