11---- ------------------------------------------------------------------------------------------------
2- -- ApacheHandlerSimple .lua
2+ -- ApacheHandlerUsingConfigFromFile .lua
33---- ------------------------------------------------------------------------------------------------
4- -- HANDLER: ApacheHandlerSimple
4+ -- HANDLER: ApacheHandlerUsingConfigFromFile
55--
66-- DESCRIPTION:
77-- This Apache httpd Lua handler verifies that HTTP requests are allowed to be passed to the
1414-- ... * QUEUEIT_INT_CONF_FILE: The local JSON file containing the integration configuration
1515-- * QUEUEIT_ERROR_CODE: (optional) The response code to use instead of declining to act
1616-- if request handling fails
17+ -- * QUEUEIT_COOKIE_OPTIONS_HTTPONLY: (optional) Set to true if you want cookies with httponly
18+ -- flag set. Only enable if this you use pure server-side integration
19+ -- e.g. not JS Hybrid
20+ -- * QUEUEIT_COOKIE_OPTIONS_SECURE: (optional) Set to true if you want cookies with secure
21+ -- flag set. Only enable if your website runs purely on https
22+ -- * QUEUEIT_COOKIE_OPTIONS_SAMESITE: (optional) Set to true if you want cookies with samesite
23+ -- flag set. Only use 'strict' if your queue protected site stays on
24+ -- same domain (no navigation to subdomains)
1725-- Note that the integration configuration is read on every request. The JSON file containing
1826-- The integration configuration should, for performance reasons, be available locally.
1927--
2533-- SetEnv QUEUEIT_SECRET_KEY "{SECRET_KEY}"
2634-- SetEnv QUEUEIT_INT_CONF_FILE "{APP_FOLDER}/integration_config.json"
2735-- SetEnv QUEUEIT_ERROR_CODE "400"
28- -- LuaMapHandler "{URI_PATTERN}" "{APP_FOLDER}/Handlers/ApacheHandlerSimple .lua"
36+ -- LuaMapHandler "{URI_PATTERN}" "{APP_FOLDER}/Handlers/ApacheHandlerUsingConfigFromFile .lua"
2937-- LuaPackagePath "{APP_FOLDER}/SDK/?.lua"
3038-- LuaPackagePath "{APP_FOLDER}/Helpers/?/?.lua"
3139-- LuaPackagePath "{APP_FOLDER}/Handlers/?.lua"
3846---- ------------------------------------------------------------------------------------------------
3947
4048
41- local DEBUG_TAG = " ApacheHandlerHelperSimple .lua"
49+ local DEBUG_TAG = " ApacheHandlerUsingConfigFromFile .lua"
4250
4351local kuHandler = require (" KnownUserApacheHandler" )
4452local file = require (" file" )
4553
46- local function initRequiredHelpers (r )
54+ local function initRequiredHelpers (r , cookieOptions )
4755 local iHelpers = require (" KnownUserImplementationHelpers" )
4856
4957 iHelpers .request .getAbsoluteUri = function ()
@@ -55,6 +63,8 @@ local function initRequiredHelpers(r)
5563 r :debug (string.format (" [%s] Rebuilt request URL as: %s" , DEBUG_TAG , fullUrl ))
5664 return fullUrl
5765 end
66+
67+ iHelpers .response .cookieOptions = cookieOptions
5868end
5969
6070function handle (r )
@@ -65,15 +75,26 @@ function handle(r)
6575 -- catch errors if any occur
6676 local success , result = pcall (function ()
6777
68- -- get configuration from environment variables
78+ -- get configuration from environment variables
6979 local customerId = r .subprocess_env [" QUEUEIT_CUSTOMER_ID" ]
7080 local secretKey = r .subprocess_env [" QUEUEIT_SECRET_KEY" ]
7181 local intConfFile = r .subprocess_env [" QUEUEIT_INT_CONF_FILE" ]
7282 local errorCode = r .subprocess_env [" QUEUEIT_ERROR_CODE" ]
83+ local cookieOptions =
84+ {
85+ httpOnly = r .subprocess_env [" QUEUEIT_COOKIE_OPTIONS_HTTPONLY" ],
86+ secure = r .subprocess_env [" QUEUEIT_COOKIE_OPTIONS_SECURE" ],
87+ sameSite = r .subprocess_env [" QUEUEIT_COOKIE_OPTIONS_SAMESITE" ]
88+ }
89+
7390 r :debug (string.format (" [%s] Environment variable QUEUEIT_CUSTOMER_ID: %s" , DEBUG_TAG , customerId ))
7491 r :debug (string.format (" [%s] Environment variable QUEUEIT_SECRET_KEY: %s" , DEBUG_TAG , secretKey ))
7592 r :debug (string.format (" [%s] Environment variable QUEUEIT_INT_CONF_FILE: %s" , DEBUG_TAG , intConfFile ))
7693 r :debug (string.format (" [%s] Environment variable QUEUEIT_ERROR_CODE: %s" , DEBUG_TAG , errorCode ))
94+ r :debug (string.format (" [%s] Environment variable QUEUEIT_COOKIE_OPTIONS_HTTPONLY: %s" , DEBUG_TAG , cookieOptions .httpOnly ))
95+ r :debug (string.format (" [%s] Environment variable QUEUEIT_COOKIE_OPTIONS_SECURE: %s" , DEBUG_TAG , cookieOptions .secure ))
96+ r :debug (string.format (" [%s] Environment variable QUEUEIT_COOKIE_OPTIONS_SAMESITE: %s" , DEBUG_TAG , cookieOptions .sameSite ))
97+
7798 assert (customerId ~= nil , " customerId invalid" )
7899 assert (secretKey ~= nil , " secretKey invalid" )
79100 assert (intConfFile ~= nil , " config invalid" )
@@ -90,7 +111,7 @@ function handle(r)
90111 r :debug (string.format (" [%s] Value of variable errorCode: %s" , DEBUG_TAG , errorCode ))
91112
92113 -- initialize helper functions
93- initRequiredHelpers (r )
114+ initRequiredHelpers (r , cookieOptions )
94115
95116 -- read integration configuration from file
96117 local intConfJson = file .readAll (intConfFile )
0 commit comments