mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[fix] Get rid of Cookie cache
This commit is contained in:
parent
e15c15812c
commit
8ee3d6b93d
1 changed files with 12 additions and 17 deletions
29
helpers.lua
29
helpers.lua
|
@ -9,7 +9,6 @@ module('helpers', package.seeall)
|
||||||
|
|
||||||
local cache = ngx.shared.cache
|
local cache = ngx.shared.cache
|
||||||
local conf = config.get_config()
|
local conf = config.get_config()
|
||||||
local cookies = {}
|
|
||||||
|
|
||||||
-- Read a FS stored file
|
-- Read a FS stored file
|
||||||
function read_file(file)
|
function read_file(file)
|
||||||
|
@ -51,14 +50,6 @@ function t (key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Set a cookie
|
|
||||||
function cook (cookie_str)
|
|
||||||
if not is_in_table(cookies, cookie_str) then
|
|
||||||
table.insert(cookies, cookie_str)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Store a message in the flash shared table in order to display it at the
|
-- Store a message in the flash shared table in order to display it at the
|
||||||
-- next response
|
-- next response
|
||||||
function flash (wat, message)
|
function flash (wat, message)
|
||||||
|
@ -119,9 +110,12 @@ function set_auth_cookie (user, domain)
|
||||||
local cookie_str = "; Domain=."..domain..
|
local cookie_str = "; Domain=."..domain..
|
||||||
"; Path=/"..
|
"; Path=/"..
|
||||||
"; Max-Age="..maxAge
|
"; Max-Age="..maxAge
|
||||||
cook("SSOwAuthUser="..user..cookie_str)
|
|
||||||
cook("SSOwAuthHash="..hash..cookie_str)
|
ngx.header["Set-Cookie"] = {
|
||||||
cook("SSOwAuthExpire="..expire..cookie_str)
|
"SSOwAuthUser="..user..cookie_str,
|
||||||
|
"SSOwAuthHash="..hash..cookie_str,
|
||||||
|
"SSOwAuthExpire="..expire..cookie_str
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,9 +126,11 @@ function delete_cookie ()
|
||||||
local cookie_str = "; Domain=."..domain..
|
local cookie_str = "; Domain=."..domain..
|
||||||
"; Path=/"..
|
"; Path=/"..
|
||||||
"; Max-Age="..expired_time
|
"; Max-Age="..expired_time
|
||||||
cook("SSOwAuthUser=;" ..cookie_str)
|
ngx.header["Set-Cookie"] = {
|
||||||
cook("SSOwAuthHash=;" ..cookie_str)
|
"SSOwAuthUser="..cookie_str,
|
||||||
cook("SSOwAuthExpire=;" ..cookie_str)
|
"SSOwAuthHash="..cookie_str,
|
||||||
|
"SSOwAuthExpire="..cookie_str
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,7 +140,7 @@ function delete_redirect_cookie ()
|
||||||
expired_time = "Thu, Jan 01 1970 00:00:00 UTC;"
|
expired_time = "Thu, Jan 01 1970 00:00:00 UTC;"
|
||||||
local cookie_str = "; Path="..conf["portal_path"]..
|
local cookie_str = "; Path="..conf["portal_path"]..
|
||||||
"; Max-Age="..expired_time
|
"; Max-Age="..expired_time
|
||||||
cook("SSOwAuthRedirect=;" ..cookie_str)
|
ngx.header["Set-Cookie"] = "SSOwAuthRedirect=;" ..cookie_str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -781,7 +777,6 @@ end
|
||||||
|
|
||||||
-- Set cookie and redirect (needed to properly set cookie)
|
-- Set cookie and redirect (needed to properly set cookie)
|
||||||
function redirect (url)
|
function redirect (url)
|
||||||
ngx.header["Set-Cookie"] = cookies
|
|
||||||
ngx.log(ngx.NOTICE, "Redirect to: "..url)
|
ngx.log(ngx.NOTICE, "Redirect to: "..url)
|
||||||
return ngx.redirect(url)
|
return ngx.redirect(url)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue