我使用Openresty作为服务器。我根据https://eclipsesource.com/blogs/2018/01/11/authenticating-reverse-proxy-with-keycloak/获得了nginx的配置文件。
我收到以下错误“openidc.lua:1053:authenticate():请求redirect_uri_path但找不到会话状态,客户端”
有人可以投入一些光并尝试解决问题。
此致 Allahbaksh
答案 0 :(得分:3)
您的重定向URI不能设置为"/"
,而是设置为不应返回内容的任意路径(如/redirect_uri
)。这是一个由lua-resty-openidc
答案 1 :(得分:0)
我遇到了同样的问题,并且能够通过在服务器块中设置 $session_name 变量来修复它。示例:
server {
...
server_name proxy.localhost;
#lua_code_cache off;
set $session_name nginx_session;
location / {
access_by_lua_block {
local opts = {
redirect_uri = "http://proxy.localhost/cb",
discovery = "http://127.0.0.1:9000/.well-known/openid-configuration",
client_id = "proxyclient-id",
client_secret = "secret",
ssl_verify = "no",
scope = "openid"
}
-- call authenticate for OpenID Connect user authentication
local res, err = require("resty.openidc").authenticate(opts)
if err then
ngx.status = 500
ngx.say(err)
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end
ngx.req.set_header("X-USER", res.id_token.sub)
}
proxy_pass http://localhost:8080/;
proxy_set_header x-forwarded-proto $scheme;
}
}
另外一个需要注意的是 lua_code_cache off 指令;它可能会中断会议。请参阅:https://github.com/bungle/lua-resty-session#notes-about-turning-lua-code-cache-off