access.lua: add special 'default' key in 'domain_portal_urls' to handle case where we reach an unmanaged domain

This commit is contained in:
Alexandre Aubin 2023-09-29 14:31:30 +02:00
parent cac360bee9
commit 769f5f9cfa

View file

@ -325,12 +325,22 @@ else
portal_domain = conf["domain_portal_urls"][ngx.var.host] portal_domain = conf["domain_portal_urls"][ngx.var.host]
if portal_domain == nil then if portal_domain == nil then
logger:debug("Domain " .. ngx.var.host .. " is not configured for SSOWat") logger:debug("Domain " .. ngx.var.host .. " is not configured for SSOWat, falling back to default")
ngx.status = 400 portal_domain = conf["domain_portal_urls"]["default"]
ngx.header.content_type = "plain/text" if portal_domain ~= nil then
ngx.say("Unmanaged domain: " .. ngx.var.host) if string.starts(portal_domain, '/') then
return portal_domain = ngx.var.host .. portal_domain
end 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 portal_url = "https://" .. portal_domain
logger:debug("Redirecting to portal : " .. portal_url) logger:debug("Redirecting to portal : " .. portal_url)