我试图在NGINX服务器上配置lua-resty-openidc。一旦用户通过身份验证,我如何重定向回主页?当用户通过身份验证时,回调url将从服务器获取代码、session_state和其他参数。一旦用户通过身份验证,这将导致加载问题。用户返回的url类似于http://xyz.abc.com:8080/secured?code=32edkew2kjjjdf。
https://github.com/pingidentity/lua-resty-openidc
我的配置如下所示。我想把用户带回http://xyz.abc.com:8080。redirect_uri应该是什么?
local opts = {
-- the full redirect URI must be protected by this script and becomes:
-- ngx.var.scheme.."://"..ngx.var.http_host..opts.redirect_uri_path
redirect_uri_path = "/secured",
discovery = "https://accounts.google.com/.well-known/openid-configuration",
client_id = "<client_id",
client_secret = "<client_secret"
--authorization_params = { hd="pingidentity.com" },
--scope = "openid email profile",
--iat_slack = 600,
}发布于 2017-03-23 12:27:31
lua-resty-openidc本身处理重定向到您试图访问的原始页面。您不需要为此做任何特定的事情,当身份验证被触发时,它会找出那个URL,请参阅:https://github.com/pingidentity/lua-resty-openidc/blob/master/lib/resty/openidc.lua#L539并将其存储在会话中。
它将截取重定向回重定向URI,请参阅:https://github.com/pingidentity/lua-resty-openidc/blob/master/lib/resty/openidc.lua#L557,并最终重定向回原始URL,请参阅https://github.com/pingidentity/lua-resty-openidc/blob/master/lib/resty/openidc.lua#L350
重定向URI本身可以是任何路径,只要它不需要为内容提供服务,Lua-R校-openidc就会拦截它并做它自己的事情。它确实需要在提供者注册。
发布于 2017-03-22 11:01:24
重定向由redirect_uri_path选项定义。您已经将/secured放到了这个字段中,因此可以重定向到http://xyz.abc.com:8080/secured?...。如果您希望重定向到/,则可以将redirect_uri_path = "/"放入您的选项中。
但是这可能不是一个好的解决方案,因为您可能希望在重定向到主页之前执行一些处理的操作。nginx.conf的以下部分可以回答您的问题:
location "=/secured" {
access_by_lua_block {
... -- perform some handling
return ngx.redirect "/"
}
}此location块是为/secured路径定义的。它允许在重定向到主页( "/“路径)之前执行一些代码。
发布于 2017-12-25 15:59:47
试试这个模块- github.com/tarachandverma/ nginx -openidc这个模块很容易用xml语法进行配置,并为简单的xml配置中的重定向提供了广泛的支持,可以在不重新启动nginx webserver的情况下进行更新。
https://stackoverflow.com/questions/42940166
复制相似问题