"ddos challenge" style script #4
1 changed files with 3 additions and 12 deletions
|
|
@ -21,12 +21,10 @@ local function getCookieValue(cookie_header, cookie_name)
|
|||
return nil
|
||||
end
|
||||
-- Parse cookie header to find our cookie
|
||||
-- Use Lua patterns instead of PCRE for better test compatibility
|
||||
local pattern = cookie_name .. "=([^;]+)"
|
||||
local match = ngx.re.match(cookie_header, pattern)
|
||||
if match then
|
||||
return match[1]
|
||||
end
|
||||
return nil
|
||||
local value = string.match(cookie_header, pattern)
|
||||
return value
|
||||
end
|
||||
|
||||
-- Question pool for multiple-choice challenges
|
||||
|
|
@ -539,19 +537,12 @@ local function challengeCallback(cfg, state)
|
|||
|
||||
-- Check for valid token cookie
|
||||
local headers = ngx.req.get_headers()
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers type = " .. type(headers))
|
||||
if headers then
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers.Cookie = " .. tostring(headers["Cookie"]))
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers.cookie = " .. tostring(headers["cookie"]))
|
||||
end
|
||||
local cookie_header = headers["Cookie"]
|
||||
local token = getCookieValue(cookie_header, cfg.cookie_name)
|
||||
ngx.log(ngx.DEBUG, "DEBUG: token extracted = " .. tostring(token))
|
||||
|
||||
if token then
|
||||
-- Verify token is still valid in shared dict
|
||||
local is_valid = state.tokens_dict:get(token)
|
||||
ngx.log(ngx.DEBUG, "DEBUG: token is_valid = " .. tostring(is_valid))
|
||||
if is_valid then
|
||||
-- Token is valid, allow request through
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue