From 70b0dbad29053534899961a8d09808b3629e6121 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 7 Aug 2014 00:48:05 +0300 Subject: [PATCH] Added a config option to set Path attribute in Set-Cookie header. --- lib/config.coffee | 1 + lib/cwmp.coffee | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/config.coffee b/lib/config.coffee index 81559d8..d45a39a 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -49,6 +49,7 @@ options = { SESSION_TIMEOUT : {type : 'int', default : 30}, GET_PARAMETER_NAMES_DEPTH_THRESHOLD : {type : 'int', default : 0}, TASK_PARAMETERS_BATCH_SIZE : {type : 'int', default : 32}, + COOKIES_PATH : {type : 'string'}, # Libxml related configuration XML_PARSE_RECOVER : {type : 'bool'}, diff --git a/lib/cwmp.coffee b/lib/cwmp.coffee index 67f956c..0b7b107 100644 --- a/lib/cwmp.coffee +++ b/lib/cwmp.coffee @@ -131,7 +131,12 @@ inform = (currentRequest, cwmpRequest) -> methodResponse : {type : 'InformResponse'}, cwmpVersion : cwmpRequest.cwmpVersion }) - res.headers['Set-Cookie'] = "session=#{currentRequest.sessionId}" + + if !!cookiesPath = config.get('COOKIES_PATH', currentRequest.session.deviceId) + res.headers['Set-Cookie'] = "session=#{currentRequest.sessionId}; Path=#{cookiesPath}" + else + res.headers['Set-Cookie'] = "session=#{currentRequest.sessionId}" + writeResponse(currentRequest, res) ) )