mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[enh] Handle local domain (yunohost.local by default) as a main domain replacement
This commit is contained in:
parent
f32f278105
commit
2e1117beff
1 changed files with 13 additions and 1 deletions
14
access.lua
14
access.lua
|
@ -41,7 +41,8 @@ end
|
|||
default_conf = {
|
||||
portal_scheme = "https",
|
||||
portal_path = "/ssowat",
|
||||
domains = { conf["portal_domain"] },
|
||||
local_portal_domain = "yunohost.local",
|
||||
domains = { conf["portal_domain"], "yunohost.local" },
|
||||
session_timeout = 60 * 60 * 24, -- one day
|
||||
session_max_timeout = 60 * 60 * 24 * 7, -- one week
|
||||
login_arg = "sso_login",
|
||||
|
@ -57,6 +58,11 @@ for param, default_value in pairs(default_conf) do
|
|||
conf[param] = conf[param] or default_value
|
||||
end
|
||||
|
||||
if ngx.var.host == conf["local_portal_domain"] then
|
||||
conf["original_portal_domain"] = conf["portal_domain"]
|
||||
conf["portal_domain"] = conf["local_portal_domain"]
|
||||
end
|
||||
|
||||
local portal_url = conf["portal_scheme"].."://"..
|
||||
conf["portal_domain"]..
|
||||
conf["portal_path"]
|
||||
|
@ -198,6 +204,9 @@ function has_access (user, url)
|
|||
return true
|
||||
end
|
||||
for u, _ in pairs(conf["users"][user]) do
|
||||
if ngx.var.host == conf["local_portal_domain"] then
|
||||
u = string.gsub(u, conf["original_portal_domain"], conf["local_portal_domain"])
|
||||
end
|
||||
if string.starts(url, string.sub(u, 1, -2)) then return true end
|
||||
end
|
||||
return false
|
||||
|
@ -411,6 +420,9 @@ function get_data_for(view)
|
|||
}
|
||||
|
||||
for url, name in pairs(conf["users"][user]) do
|
||||
if ngx.var.host == conf["local_portal_domain"] then
|
||||
url = string.gsub(url, conf["original_portal_domain"], conf["local_portal_domain"])
|
||||
end
|
||||
table.insert(data["app"], { url = url, name = name })
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue