Merge pull request #183 from YunoHost/avoid-a-syscall-for-cookies

Avoid a syscall for cookies
This commit is contained in:
Alexandre Aubin 2021-04-08 15:38:18 +02:00 committed by GitHub
commit 2e8c2f9c67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -176,7 +176,7 @@ function set_auth_cookie(user, domain)
"|"..session_key) "|"..session_key)
local cookie_str = "; Domain=."..domain.. local cookie_str = "; Domain=."..domain..
"; Path=/".. "; Path=/"..
"; Expires="..os.date("%a, %d %b %Y %X UTC", expire).. "; Expires="..ngx.cookie_time(expire)..
"; Secure".. "; Secure"..
"; HttpOnly".. "; HttpOnly"..
"; SameSite=Lax" "; SameSite=Lax"
@ -192,11 +192,10 @@ end
-- Expires the 3 session cookies -- Expires the 3 session cookies
function delete_cookie() function delete_cookie()
local expired_time = "Thu, 01 Jan 1970 00:00:00 UTC"
for _, domain in ipairs(conf["domains"]) do for _, domain in ipairs(conf["domains"]) do
local cookie_str = "; Domain=."..domain.. local cookie_str = "; Domain=."..domain..
"; Path=/".. "; Path=/"..
"; Expires="..expired_time.. "; Expires="..ngx.cookie_time(0)..
"; Secure".. "; Secure"..
"; HttpOnly".. "; HttpOnly"..
"; SameSite=Lax" "; SameSite=Lax"