"ddos challenge" style script #4
2 changed files with 13 additions and 0 deletions
Add debug logging to diagnose token validation failures
Added debug logging to see what's happening with cookie header parsing in the failing token validation tests. This will help identify whether: - ngx.req.get_headers() is returning the expected headers - The Cookie header is being found (case sensitivity check) - The token is being extracted correctly - The token is found in the shared dict Also added ngx log level constants (DEBUG, INFO, WARN, ERR) to the test framework since the module uses them.
commit
d8b1b861ab
|
|
@ -539,12 +539,19 @@ local function challengeCallback(cfg, state)
|
||||||
|
|
||||||
-- Check for valid token cookie
|
-- Check for valid token cookie
|
||||||
local headers = ngx.req.get_headers()
|
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 cookie_header = headers["Cookie"]
|
||||||
local token = getCookieValue(cookie_header, cfg.cookie_name)
|
local token = getCookieValue(cookie_header, cfg.cookie_name)
|
||||||
|
ngx.log(ngx.DEBUG, "DEBUG: token extracted = " .. tostring(token))
|
||||||
|
|
||||||
if token then
|
if token then
|
||||||
-- Verify token is still valid in shared dict
|
-- Verify token is still valid in shared dict
|
||||||
local is_valid = state.tokens_dict:get(token)
|
local is_valid = state.tokens_dict:get(token)
|
||||||
|
ngx.log(ngx.DEBUG, "DEBUG: token is_valid = " .. tostring(is_valid))
|
||||||
if is_valid then
|
if is_valid then
|
||||||
-- Token is valid, allow request through
|
-- Token is valid, allow request through
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
6
test.lua
6
test.lua
|
|
@ -20,6 +20,12 @@ function createNgx()
|
||||||
print(msg)
|
print(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Log level constants
|
||||||
|
ngx.DEBUG = 7
|
||||||
|
ngx.INFO = 6
|
||||||
|
ngx.WARN = 4
|
||||||
|
ngx.ERR = 3
|
||||||
|
|
||||||
-- only hold data here
|
-- only hold data here
|
||||||
ngx.var = {}
|
ngx.var = {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue