Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

secureProxy is deprecated in cookies #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/client-sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,12 @@ function clientSessionFactory(opts) {
if (propertyName in req) {
return next(); //self aware
}

var cookies = new Cookies(req, res);
var options
if (opts.cookie.secureProxy) {
options = { secure: opts.cookie.secureProxy }
delete opts.cookie.secureProxy
}
var cookies = new Cookies(req, res, options);
var rawSession;
try {
rawSession = new Session(req, res, cookies, opts);
Expand Down
47 changes: 47 additions & 0 deletions test/all-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,27 @@ function create_app_with_secure(firstMiddleware) {
return app;
}

function create_app_with_secure_proxy(firstMiddleware) {
// set up the session middleware
var middleware = cookieSessions({
cookieName: 'session',
secret: 'yo',
activeDuration: 0,
cookie: {
maxAge: 5000,
secureProxy: true
}
});

var app = express();
if (firstMiddleware)
app.use(firstMiddleware);

app.use(middleware);

return app;
}

suite.addBatch({
"across two requests, without proxySecure, secure cookies" : {
topic: function() {
Expand All @@ -862,6 +883,32 @@ suite.addBatch({
}
});

suite.addBatch({
"across two requests, with secureProxy, secure cookies" : {
topic: function() {
var self = this;
var app = create_app_with_secure_proxy();

app.get("/foo", function(req, res) {
req.session.reset();
req.session.foo = 'bar'
res.send("foo");
});

var browser = createBrowser(app);
browser.get("/foo", function(res, $) {
browser.done();
self.callback(null, res);
});

},
"can be set": function(err, res) {
assert.match(res.headers['set-cookie'], /secure/)
assert.equal(res.statusCode, 200);
}
}
});

suite.addBatch({
"across two requests, with proxySecure, secure cookies" : {
topic: function() {
Expand Down