feat: add per-user cookie generation

This commit is contained in:
Eugene Prodan
2021-06-14 23:00:04 +03:00
parent 26ae929644
commit 7a1a91f0e8
3 changed files with 27 additions and 3 deletions

View File

@ -68,7 +68,7 @@ function _M.view(applet)
end
if api_response.success == true then
local floating_hash = applet.sc:xxh32(utils.get_hostname())
local floating_hash = utils.generate_secret{context=applet, mode='service'}
core.Debug("HCAPTCHA SUCCESSFULLY PASSED")
applet:add_header(
"set-cookie",
@ -95,7 +95,7 @@ function _M.check_captcha_status(txn)
core.Debug("CAPTCHA STATUS CHECK START")
txn:set_var("txn.requested_url", "/mopsik?kek=pek")
local parsed_request_cookies = cookie.get_cookie_table(txn.sf:hdr("Cookie"))
local expected_cookie = txn.sc:xxh32(utils.get_hostname())
local expected_cookie = utils.generate_secret{context=txn, mode='service'}
core.Debug("RECEIVED SECRET COOKIE: " .. parsed_request_cookies["z_ddos_protection"])
core.Debug("OUR SECRET COOKIE: " .. expected_cookie)