环境
这就是我要做的
关于信息,我在我们的ingress-nginx-controller上使用它,将整个内容从/usr/local/openresty/lualib/resty复制到/etc/nginx/lua/。当UI端点(即https://ingress.myproject.local/myui)被调用时,它应该将连接重定向到Keycloak。我有一个名为myui的客户端,它位于Keycloak的主域之下。
这是我的当前代码
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,并带有错误消息:
[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
发布于 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")。
https://stackoverflow.com/questions/72219190
复制相似问题