带 Passport NodeJ 的集群
Cluster with Passport NodeJs
在我们的应用程序中,我们使用 Passport 中间件(localStrategy,会话存储在 MongoStore 中)。我们决定使用集群来加速和简化服务器。
问题是在这个改变之后,passport 总是处于 "not authorized" 状态。
是否可以将 passport (localStrategy) 与集群一起使用?
Passport 在内存中存储会话数据。使用集群,护照可以将数据存储在集群中,其他请求由其他集群处理。您必须使用会话存储。我建议使用 connect-redis
这些链接也很有用:
1-https://blog.risingstack.com/node-hero-node-js-authentication-passport-js/
2-Using passport and OAuth with connect-redis
3-https://afshinm.name/2014/06/26/using-redis-as-session-store-for-expressjs-passportjs-settings/
4-https://www.airpair.com/express/posts/expressjs-and-passportjs-sessions-deep-dive
更新
MongoDb 阅读这些链接
1-
2-How can I manage sessions with Passport JS for some routes using express?
在我们的应用程序中,我们使用 Passport 中间件(localStrategy,会话存储在 MongoStore 中)。我们决定使用集群来加速和简化服务器。 问题是在这个改变之后,passport 总是处于 "not authorized" 状态。 是否可以将 passport (localStrategy) 与集群一起使用?
Passport 在内存中存储会话数据。使用集群,护照可以将数据存储在集群中,其他请求由其他集群处理。您必须使用会话存储。我建议使用 connect-redis
这些链接也很有用:
1-https://blog.risingstack.com/node-hero-node-js-authentication-passport-js/
2-Using passport and OAuth with connect-redis
3-https://afshinm.name/2014/06/26/using-redis-as-session-store-for-expressjs-passportjs-settings/
4-https://www.airpair.com/express/posts/expressjs-and-passportjs-sessions-deep-dive
更新
MongoDb 阅读这些链接
1-
2-How can I manage sessions with Passport JS for some routes using express?