Express with Passport 認証があり、以下のようにセッションを追加しました。
app.use(cookieParser()); // read cookies (needed for auth)
app.use(bodyParser()); // get information from html forms
app.set('view engine', 'ejs'); // set up ejs for templating
// required for passport
// Trust Proxy as it is behind web server.
//app.set('trust proxy', 1);
app.use(session({
secret: 'this is secret',
resave: false,
store: new MongoStore({ url: configDB.url }),
saveUninitialized: true,
cookie: { httpOnly: true, maxAge: 2419200000 }
})); // session secret
app.get("/*", function(req, res, next) {
if (typeof req.cookies['connect.sid'] !== 'undefined') { console.log(req.cookies['connect.sid']); }
next(); // call the next middleware
});
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session
Passport ログインで、セッション名を として設定していreq.session.name
ます。ユーザー A がログインした場合は問題なく動作しますが、ユーザー B がログインした場合、新しいセッション オブジェクトは作成されませんが、パスポートの詳細を含むユーザー B でユーザー A のセッション オブジェクトが上書きされます。また、ブラウザーでは、Cookie がユーザー B にリセットされますが、これは明らかです。