mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
do not reauth if we are already logged in
This commit is contained in:
parent
24b3f7dc3a
commit
720e35df4e
1 changed files with 18 additions and 16 deletions
34
access.lua
34
access.lua
|
@ -249,25 +249,27 @@ end
|
||||||
-- via cURL for example.
|
-- via cURL for example.
|
||||||
--
|
--
|
||||||
|
|
||||||
local auth_header = ngx.req.get_headers()["Authorization"]
|
if not is_logged_in then
|
||||||
|
local auth_header = ngx.req.get_headers()["Authorization"]
|
||||||
|
|
||||||
if auth_header then
|
if auth_header then
|
||||||
_, _, b64_cred = string.find(auth_header, "^Basic%s+(.+)$")
|
_, _, b64_cred = string.find(auth_header, "^Basic%s+(.+)$")
|
||||||
_, _, user, password = string.find(ngx.decode_base64(b64_cred), "^(.+):(.+)$")
|
_, _, user, password = string.find(ngx.decode_base64(b64_cred), "^(.+):(.+)$")
|
||||||
user = hlp.authenticate(user, password)
|
user = hlp.authenticate(user, password)
|
||||||
if user then
|
if user then
|
||||||
logger.debug("User got authenticated through basic auth")
|
logger.debug("User got authenticated through basic auth")
|
||||||
|
|
||||||
-- If user has no access to this URL, redirect him to the portal
|
-- If user has no access to this URL, redirect him to the portal
|
||||||
if not permission or not hlp.has_access(permission, user) then
|
if not permission or not hlp.has_access(permission, user) then
|
||||||
return hlp.redirect(conf.portal_url)
|
return hlp.redirect(conf.portal_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
if permission["auth_header"] then
|
||||||
|
logger.debug("Set Headers")
|
||||||
|
hlp.set_headers(user)
|
||||||
|
end
|
||||||
|
return hlp.pass()
|
||||||
end
|
end
|
||||||
|
|
||||||
if permission["auth_header"] then
|
|
||||||
logger.debug("Set Headers")
|
|
||||||
hlp.set_headers(user)
|
|
||||||
end
|
|
||||||
return hlp.pass()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue