lua-resty-openidc icon indicating copy to clipboard operation
lua-resty-openidc copied to clipboard

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

Open dsantanu opened this issue 2 years ago • 1 comments

Environment
  • lua-resty-openidc version : 1.7.5
  • OpenID Connect provider: Keycloak
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

dsantanu avatar May 12 '22 16:05 dsantanu

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?

bodewig avatar Feb 08 '23 06:02 bodewig