Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update Readme and examples for new `secret` options

cookieSession and session now accept a `secret` option. This is the
prefered way to use these middleware now so the Readme and examples are
updated accordingly.

cookieParser docs still indication signed cookie support just not for
the `session` middleware explicitly
  • Loading branch information...
commit 1e57e03617cf6930eeb445b08c1ce34a5c4b5030 1 parent 5a85b18
@defunctzombie defunctzombie authored
View
6 Readme.md
@@ -14,8 +14,8 @@ var app = connect()
.use(connect.logger('dev'))
.use(connect.static('public'))
.use(connect.directory('public'))
- .use(connect.cookieParser('my secret here'))
- .use(connect.session())
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'my secret here' }))
.use(function(req, res){
res.end('Hello from Connect!\n');
});
@@ -129,4 +129,4 @@ then:
## License
-View the [LICENSE](https://github.com/senchalabs/connect/blob/master/LICENSE) file. The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons used by the `directory` middleware created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
+View the [LICENSE](https://github.com/senchalabs/connect/blob/master/LICENSE) file. The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons used by the `directory` middleware created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
View
6 examples/cookieSession.js
@@ -5,8 +5,8 @@ var connect = require('../')
var app = connect()
.use(connect.logger('dev'))
.use(connect.bodyParser())
- .use(connect.cookieParser('some secret'))
- .use(connect.cookieSession())
+ .use(connect.cookieParser())
+ .use(connect.cookieSession({ secret: 'some secret' }))
.use(post)
.use(clear)
.use(counter);
@@ -38,4 +38,4 @@ function counter(req, res) {
}
http.createServer(app).listen(3000);
-console.log('Server listening on port 3000');
+console.log('Server listening on port 3000');
View
6 examples/csrf.js
@@ -15,8 +15,8 @@ var form = '\n\
';
var app = connect()
- .use(connect.cookieParser('keyboard cat'))
- .use(connect.session())
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'keyboard cat' }))
.use(connect.bodyParser())
.use(connect.csrf())
.use(function(req, res, next){
@@ -33,4 +33,4 @@ var app = connect()
});
http.createServer(app).listen(3000);
-console.log('Server listening on port 3000');
+console.log('Server listening on port 3000');
View
25 examples/session.js
@@ -7,8 +7,8 @@ var connect = require('../')
// receive req.session
http.createServer(connect()
- .use(connect.cookieParser('keyboard cat'))
- .use(connect.session({ cookie: { maxAge: 60000 }}))
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
.use(connect.favicon())
.use(function(req, res, next){
var sess = req.session;
@@ -31,8 +31,9 @@ console.log('port 3000: 1 minute expiration demo');
try {
var RedisStore = require('connect-redis')(connect);
http.createServer(connect()
- .use(connect.cookieParser('keyboard cat'))
+ .use(connect.cookieParser())
.use(connect.session({
+ secret: 'keyboard cat',
cookie: { maxAge: 60000 * 3 }
, store: new RedisStore
}))
@@ -64,10 +65,10 @@ try {
// conditional session support by simply
// wrapping middleware with middleware.
-var sess = connect.session({ cookie: { maxAge: 5000 }});
+var sess = connect.session({ secret: 'keyboard cat', cookie: { maxAge: 5000 }});
http.createServer(connect()
- .use(connect.cookieParser('keyboard cat'))
+ .use(connect.cookieParser())
.use(function(req, res, next){
if ('/foo' == req.url || '/bar' == req.url) {
sess(req, res, next);
@@ -90,8 +91,8 @@ console.log('port 3002: conditional sessions');
// session data
http.createServer(connect()
- .use(connect.cookieParser('keyboard cat'))
- .use(connect.session({ cookie: { maxAge: 60000 }}))
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
.use(connect.favicon())
.use(function(req, res, next){
var sess = req.session
@@ -125,8 +126,8 @@ console.log('port 3003: Session#reload() demo');
// aka while the browser is open.
http.createServer(connect()
- .use(connect.cookieParser('keyboard cat'))
- .use(connect.session())
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'keyboard cat' }))
.use(connect.favicon())
.use(function(req, res, next){
var sess = req.session;
@@ -147,8 +148,8 @@ console.log('port 3004: browser-session length sessions');
http.createServer(connect()
.use(connect.bodyParser())
- .use(connect.cookieParser('keyboard cat'))
- .use(connect.session())
+ .use(connect.cookieParser())
+ .use(connect.session({ secret: 'keyboard cat' }))
.use(connect.favicon())
.use(function(req, res, next){
if ('POST' != req.method) return next();
@@ -168,4 +169,4 @@ http.createServer(connect()
+ '</form>');
})).listen(3005);
-console.log('port 3005: browser-session length sessions persistence example');
+console.log('port 3005: browser-session length sessions persistence example');
View
4 lib/middleware/cookieParser.js
@@ -20,12 +20,12 @@ var utils = require('./../utils')
* with an object keyed by the cookie names. Optionally
* you may enabled signed cookie support by passing
* a `secret` string, which assigns `req.secret` so
- * it may be used by other middleware such as `session()`.
+ * it may be used by other middleware.
*
* Examples:
*
* connect()
- * .use(connect.cookieParser('keyboard cat'))
+ * .use(connect.cookieParser('optional secret string'))
* .use(function(req, res, next){
* res.end(JSON.stringify(req.cookies));
* })
Please sign in to comment.
Something went wrong with that request. Please try again.