Comparing version 0.5.1 to 0.5.2
@@ -0,1 +1,4 @@ | ||
[0.5.2] | ||
* Added "secureCookies" option to "https" config. By default, all cookies set during an HTTPS request are secure. Setting this option to false allows non-secure cookies to be set by secure pages. | ||
[0.5.1] | ||
@@ -2,0 +5,0 @@ * Forgot to update the config builder in util/scaffold.js with the new HTTP config |
@@ -24,3 +24,4 @@ // Initializes the framework | ||
hostname: '127.0.0.1', | ||
port: 443 | ||
port: 443, | ||
secureCookies: true | ||
}, | ||
@@ -27,0 +28,0 @@ connectionQueue: null, |
@@ -22,2 +22,3 @@ // router | ||
route = { | ||
parsed: parsed, | ||
url: parsed.href, | ||
@@ -24,0 +25,0 @@ pathname: pathToParse, |
@@ -103,10 +103,14 @@ // server | ||
serverDomain.run( function () { | ||
var hostname, | ||
var protocol, | ||
hostname, | ||
port; | ||
if ( options.pfx || ( options.key && options.cert ) ) { | ||
protocol = 'https'; | ||
hostname = options.hostname || CTZN.config.citizen.https.hostname; | ||
port = options.port || CTZN.config.citizen.https.port; | ||
https.createServer(options, serve).listen(port, hostname, CTZN.config.citizen.connectionQueue, function () { | ||
https.createServer(options, function (request, response) { | ||
serve(request, response, protocol); | ||
}).listen(port, hostname, CTZN.config.citizen.connectionQueue, function () { | ||
var httpsHostname = hostname.length ? hostname : '127.0.0.1', | ||
@@ -139,6 +143,9 @@ appUrl = port === 443 ? 'https://' + httpsHostname + CTZN.config.citizen.urlPaths.app : 'https://' + httpsHostname + ':' + port + CTZN.config.citizen.urlPaths.app, | ||
} else { | ||
protocol = 'http'; | ||
hostname = options.hostname || CTZN.config.citizen.http.hostname; | ||
port = options.port || CTZN.config.citizen.http.port; | ||
http.createServer(serve).listen(port, hostname, CTZN.config.citizen.connectionQueue, function () { | ||
http.createServer( function (request, response) { | ||
serve(request, response, protocol); | ||
}).listen(port, hostname, CTZN.config.citizen.connectionQueue, function () { | ||
var httpHostname = hostname.length ? hostname : '127.0.0.1', | ||
@@ -176,3 +183,3 @@ appUrl = port === 80 ? 'http://' + httpHostname + CTZN.config.citizen.urlPaths.app : 'http://' + httpHostname + ':' + port + CTZN.config.citizen.urlPaths.app, | ||
function serve(request, response) { | ||
function serve(request, response, protocol) { | ||
var context = {}, | ||
@@ -182,3 +189,3 @@ params = { | ||
response: response, | ||
route: router.getRoute('http://' + request.headers.host + request.url), | ||
route: router.getRoute(protocol + '://' + request.headers.host + request.url), | ||
url: router.getUrlParams(request.url), | ||
@@ -276,3 +283,3 @@ form: {}, | ||
function setCookie(params, context) { | ||
var cookie = buildCookie(context.cookie); | ||
var cookie = buildCookie(context.cookie, params); | ||
if ( cookie.length ) { | ||
@@ -489,3 +496,3 @@ params.response.setHeader('Set-Cookie', cookie); | ||
params.response.setHeader('X-Powered-By', 'citizen'); | ||
switch ( params.request.method ) { | ||
@@ -1249,3 +1256,3 @@ case 'GET': | ||
function buildCookie(cookies) { | ||
function buildCookie(cookies, params) { | ||
var defaults = {}, | ||
@@ -1257,3 +1264,3 @@ cookie = {}, | ||
httpOnly = 'HttpOnly;', | ||
secure = '', | ||
secure = params.route.parsed.protocol === 'https:' && CTZN.config.citizen.https.secureCookies ? 'secure;' : '', | ||
cookieExpires, | ||
@@ -1265,3 +1272,3 @@ now = Date.now(); | ||
if ( cookies[property].constructor.toString().indexOf('Object') < 0 ) { | ||
cookieArray.push(property + '=' + cookies[property] + ';path=/;HttpOnly;'); | ||
cookieArray.push(property + '=' + cookies[property] + ';path=/;HttpOnly;' + secure); | ||
} else { | ||
@@ -1300,3 +1307,3 @@ defaults = { | ||
} | ||
if ( cookie.secure ) { | ||
if ( cookie.secure || ( params.route.parsed.protocol === 'https:' && CTZN.config.citizen.https.secureCookies ) ) { | ||
secure = 'secure;'; | ||
@@ -1303,0 +1310,0 @@ } |
{ | ||
"name": "citizen", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "A server-side MVC and caching framework for Node.js web applications.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198313
2817
2246