added httponly true by default, updated readme
This commit is contained in:
Родитель
f21d1348db
Коммит
eaaac62165
|
@ -22,7 +22,7 @@ API
|
||||||
cookie: {
|
cookie: {
|
||||||
path: '/api',
|
path: '/api',
|
||||||
httpOnly: true, // defaults to true
|
httpOnly: true, // defaults to true
|
||||||
secure: true // defaults to true
|
secure: false // defaults to false
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,19 @@ var cookieSession = function(opts) {
|
||||||
|
|
||||||
opts.cookieName = opts.cookieName || "session";
|
opts.cookieName = opts.cookieName || "session";
|
||||||
|
|
||||||
|
// set up cookie defaults
|
||||||
|
opts.cookie = opts.cookie || {};
|
||||||
|
if (typeof(opts.cookie.httpOnly) == 'undefined')
|
||||||
|
opts.cookie.httpOnly = true;
|
||||||
|
|
||||||
|
// let's not default to secure just yet,
|
||||||
|
// as this depends on the socket being secure,
|
||||||
|
// which is tricky to determine if proxied.
|
||||||
|
/*
|
||||||
|
if (typeof(opts.cookie.secure) == 'undefined')
|
||||||
|
opts.cookie.secure = true;
|
||||||
|
*/
|
||||||
|
|
||||||
// support for maxAge
|
// support for maxAge
|
||||||
if (opts.cookie.maxAge) {
|
if (opts.cookie.maxAge) {
|
||||||
opts.cookie.expires = new Date(new Date().getTime() + opts.cookie.maxAge);
|
opts.cookie.expires = new Date(new Date().getTime() + opts.cookie.maxAge);
|
||||||
|
|
|
@ -86,6 +86,9 @@ suite.addBatch({
|
||||||
},
|
},
|
||||||
"with a path attribute": function(err, res) {
|
"with a path attribute": function(err, res) {
|
||||||
assert.match(res.headers['set-cookie'][0], /path/);
|
assert.match(res.headers['set-cookie'][0], /path/);
|
||||||
|
},
|
||||||
|
"with an httpOnly attribute": function(err, res) {
|
||||||
|
assert.match(res.headers['set-cookie'][0], /httponly/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче