mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
fix the redirect loop \o/
This commit is contained in:
parent
0f1eea3306
commit
400f88e6ca
2 changed files with 13 additions and 9 deletions
20
access.lua
20
access.lua
|
@ -343,16 +343,20 @@ end
|
||||||
-- The default is to protect every URL by default.
|
-- The default is to protect every URL by default.
|
||||||
--
|
--
|
||||||
|
|
||||||
-- Only display this if HTTPS. For HTTP, we can't know if the user really is
|
|
||||||
-- logged in or not, because the cookie is available only in HTTP...
|
|
||||||
if ngx.var.scheme == "https" then
|
|
||||||
hlp.flash("info", hlp.t("please_login"))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Force the scheme to HTTPS. This is to avoid an issue with redirection loop
|
-- Force the scheme to HTTPS. This is to avoid an issue with redirection loop
|
||||||
-- when trying to access http://main.domain.tld/ (SSOwat finds that user aint
|
-- when trying to access http://main.domain.tld/ (SSOwat finds that user aint
|
||||||
-- logged in, therefore redirects to SSO, which redirects to the back_url, which
|
-- logged in, therefore redirects to SSO, which redirects to the back_url, which
|
||||||
-- redirect to SSO, ..)
|
-- redirect to SSO, ..)
|
||||||
logger.debug("No rule found for "..ngx.var.uri..". By default, redirecting to portal")
|
logger.debug("No rule found for "..ngx.var.uri..". By default, redirecting to portal")
|
||||||
local back_url = "https://" .. ngx.var.host .. ngx.var.uri .. hlp.uri_args_string()
|
if is_logged_in then
|
||||||
return hlp.redirect(conf.portal_url.."?r="..ngx.encode_base64(back_url))
|
return hlp.redirect(conf.portal_url)
|
||||||
|
else
|
||||||
|
-- Only display this if HTTPS. For HTTP, we can't know if the user really is
|
||||||
|
-- logged in or not, because the cookie is available only in HTTP...
|
||||||
|
if ngx.var.scheme == "https" then
|
||||||
|
hlp.flash("info", hlp.t("please_login"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local back_url = "https://" .. ngx.var.host .. ngx.var.uri .. hlp.uri_args_string()
|
||||||
|
return hlp.redirect(conf.portal_url.."?r="..ngx.encode_base64(back_url))
|
||||||
|
end
|
||||||
|
|
|
@ -82,7 +82,7 @@ function get_config()
|
||||||
|
|
||||||
|
|
||||||
-- Always skip the portal to avoid redirection looping.
|
-- Always skip the portal to avoid redirection looping.
|
||||||
table.insert(conf["skipped_urls"], conf["portal_domain"]..conf["portal_path"])
|
table.insert(conf["permissions"]["core_skipped"]["uris"], conf["portal_domain"]..conf["portal_path"])
|
||||||
|
|
||||||
|
|
||||||
-- Set the prefered language from the `Accept-Language` header
|
-- Set the prefered language from the `Accept-Language` header
|
||||||
|
|
Loading…
Add table
Reference in a new issue