首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Lua-R校-openidc:入口线程中止:运行时错误:尝试调用字段'start‘(一个零值)

Lua-R校-openidc:入口线程中止:运行时错误:尝试调用字段'start‘(一个零值)
EN

Stack Overflow用户
提问于 2022-05-12 16:30:54
回答 1查看 529关注 0票数 0

环境

  • lua-resty-openidc : v1.7.5
  • OpenID连接提供程序: Keycloak

这就是我要做的

关于信息,我在我们的ingress-nginx-controller上使用它,将整个内容从/usr/local/openresty/lualib/resty复制到/etc/nginx/lua/。当UI端点(即https://ingress.myproject.local/myui)被调用时,它应该将连接重定向到Keycloak。我有一个名为myui的客户端,它位于Keycloak的主域之下。

这是我的当前代码

代码语言:javascript
运行
复制
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;
  }
}

这就是我得到的

在运行时,我在浏览器上获得500 Internal Server Error,并带有错误消息:

代码语言:javascript
运行
复制
[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"

我看不出日志中有什么与此相关的重要内容。知道我为什么要得到这个吗?或者我做错了什么?

-S

EN

回答 1

Stack Overflow用户

发布于 2022-05-12 17:25:24

https://github.com/zmartzone/lua-resty-openidc的文档说:

需要安装两个额外的纯Lua依赖项,它们实现会话管理和HTTP函数:

看来你没有安装Lua-R校会话。您所得到的错误是因为r_session是零,它被定义为local r_session = require("resty.session")

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72219190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档