diff --git a/access.lua b/access.lua index e5425f7..a734897 100644 --- a/access.lua +++ b/access.lua @@ -37,7 +37,7 @@ end function set_auth_cookie (user, domain) local maxAge = 60 * 60 * 24 * 7 -- 1 week local expire = ngx.req.start_time() + maxAge - local hash = ngx.md5(auth_key.. + local hash = ngx.md5(srvkey.. "|" ..ngx.var.remote_addr.. "|"..user.. "|"..expire) @@ -99,7 +99,7 @@ function check_cookie () -- Check expire time if (ngx.req.start_time() <= tonumber(ngx.var.cookie_SSOwAuthExpire)) then -- Check hash - local hash = ngx.md5(auth_key.. + local hash = ngx.md5(srvkey.. "|"..ngx.var.remote_addr.. "|"..ngx.var.cookie_SSOwAuthUser.. "|"..ngx.var.cookie_SSOwAuthExpire) diff --git a/init.lua b/init.lua index d17c041..fbb072e 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,7 @@ math = require "math" -- Set random key math.randomseed(os.time()) -auth_key = math.random(1111111, 9999999) +srvkey = math.random(1111111, 9999999) -- Shared table tokens = {}