-
-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added auto sub domain feature for cookies #311
base: master
Are you sure you want to change the base?
Changes from all commits
171d8b6
59b1f56
db2a442
30a3f49
005078a
b9ecf9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ var Session = require('./session/session') | |
, Cookie = require('./session/cookie') | ||
, Store = require('./session/store') | ||
|
||
var parseDomain = require('parse-domain'); | ||
// environment | ||
|
||
var env = process.env.NODE_ENV; | ||
|
@@ -146,6 +147,13 @@ function session(options){ | |
if (cookieOptions.secure === 'auto') { | ||
req.session.cookie.secure = issecure(req, trustProxy); | ||
} | ||
|
||
if (cookieOptions.autoSubDomain) { | ||
var parsedDomain = parseDomain(req.headers.host); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of only using |
||
if (parsedDomain && parsedDomain.domain) { | ||
req.session.cookie.domain = '.' + parsedDomain.domain + '.' + parsedDomain.tld; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious here: why is the option called |
||
} | ||
} | ||
}; | ||
|
||
var storeImplementsTouch = typeof store.touch === 'function'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "express-session", | ||
"version": "1.13.0", | ||
"version": "1.13.1", | ||
"description": "Simple session middleware for Express", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)", | ||
"contributors": [ | ||
|
@@ -18,7 +18,8 @@ | |
"on-headers": "~1.0.1", | ||
"parseurl": "~1.3.1", | ||
"uid-safe": "~2.1.0", | ||
"utils-merge": "1.0.0" | ||
"utils-merge": "1.0.0", | ||
"parse-domain": "^0.2.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use an exact version and order this to be alphabetical (otherwise |
||
}, | ||
"devDependencies": { | ||
"after": "0.8.1", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can, please move this up with the other requires (probably right before the
parseUrl
one).