mirror of
https://github.com/openappsec/attachment.git
synced 2025-12-31 13:49:09 +03:00
move check
This commit is contained in:
@@ -17,25 +17,25 @@ function NanoHandler.access(conf)
|
|||||||
|
|
||||||
-- Check if we already have a finalized session from a previous phase
|
-- Check if we already have a finalized session from a previous phase
|
||||||
local ctx = kong.ctx.plugin
|
local ctx = kong.ctx.plugin
|
||||||
if nano.is_session_finalized(ctx.session_data) then
|
|
||||||
kong.log.info("Session has already been inspected, no need for further inspection")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local headers = kong.request.get_headers()
|
local headers = kong.request.get_headers()
|
||||||
local session_id = nano.generate_session_id()
|
local session_id = nano.generate_session_id()
|
||||||
-- I don't think we need to set this header, but keeping it for now
|
-- I don't think we need to set this header, but keeping it for now
|
||||||
kong.service.request.set_header("x-session-id", tostring(session_id))
|
kong.service.request.set_header("x-session-id", tostring(session_id))
|
||||||
|
|
||||||
local session_data = nano.init_session(session_id)
|
local session_data = nano.init_session(session_id)
|
||||||
if not session_data then
|
if not session_data then
|
||||||
--kong.log.err("Failed to initialize session - failing open")
|
--kong.log.err("Failed to initialize session - failing open")
|
||||||
kong.ctx.plugin.cleanup_needed = false
|
kong.ctx.plugin.cleanup_needed = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
kong.ctx.plugin.session_data = session_data
|
kong.ctx.plugin.session_data = session_data
|
||||||
kong.ctx.plugin.session_id = session_id
|
kong.ctx.plugin.session_id = session_id
|
||||||
|
if nano.is_session_finalized(session_id) then
|
||||||
|
kong.log.info("Session has already been inspected, no need for further inspection")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local meta_data = nano.handle_start_transaction()
|
local meta_data = nano.handle_start_transaction()
|
||||||
kong.ctx.plugin.meta_data = meta_data -- Keep reference to prevent GC
|
kong.ctx.plugin.meta_data = meta_data -- Keep reference to prevent GC
|
||||||
|
|||||||
Reference in New Issue
Block a user