mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
access.lua: add special 'default' key in 'domain_portal_urls' to handle case where we reach an unmanaged domain
This commit is contained in:
parent
cac360bee9
commit
769f5f9cfa
1 changed files with 15 additions and 5 deletions
20
access.lua
20
access.lua
|
@ -325,12 +325,22 @@ else
|
|||
|
||||
portal_domain = conf["domain_portal_urls"][ngx.var.host]
|
||||
if portal_domain == nil then
|
||||
logger:debug("Domain " .. ngx.var.host .. " is not configured for SSOWat")
|
||||
ngx.status = 400
|
||||
ngx.header.content_type = "plain/text"
|
||||
ngx.say("Unmanaged domain: " .. ngx.var.host)
|
||||
return
|
||||
logger:debug("Domain " .. ngx.var.host .. " is not configured for SSOWat, falling back to default")
|
||||
portal_domain = conf["domain_portal_urls"]["default"]
|
||||
if portal_domain ~= nil then
|
||||
if string.starts(portal_domain, '/') then
|
||||
portal_domain = ngx.var.host .. portal_domain
|
||||
end
|
||||
return ngx.redirect("https://" .. portal_domain)
|
||||
end
|
||||
end
|
||||
if portal_domain == nil then
|
||||
ngx.header['Content-Type'] = "text/html"
|
||||
ngx.status = 400
|
||||
ngx.say("Unmanaged domain")
|
||||
return ngx.exit(200)
|
||||
end
|
||||
|
||||
portal_url = "https://" .. portal_domain
|
||||
logger:debug("Redirecting to portal : " .. portal_url)
|
||||
|
||||
|
|
Loading…
Reference in a new issue