简体   繁体   English

如何在 Feathers js 中使用传统会话

[英]How to use traditional sessions in Feathers js

Feathers auth provides only JWT authentication, even if strategy is local. Feathers auth 仅提供 JWT 身份验证,即使策略是本地的。 Should I make full custom middleware for express-session usage and clean passport implimentation just to achive regular sessions behaviour or there's some solutions for this purpose?我应该为express-session使用和干净的passport实现制作完整的自定义中间件来实现常规会话行为还是为此目的有一些解决方案?

Also, I want to use passport.socketio for autheticate sockets aswell.另外,我也想使用passport.socketio来验证套接字。

Using Feathers authentication module is entirely optional and you can always register your own middleware at any point like before and after a service .使用 Feathers 身份验证模块是完全可选的,您可以随时注册自己的中间件,例如服务之前和之后 This means you can set up a normal Express session setup and then set req.feathers to the information from the session that you also want to pass to Feathers services (like the user).这意味着您可以设置正常的 Express 会话设置,然后将req.feathers设置为您还想传递给 Feathers 服务(如用户)的会话信息。 As you mentioned, you will have to do the same thing with websockets (which also allow setting handshake.feathers in its middleware).正如您所提到的,您必须对 websockets 做同样的事情(它还允许在其中间件中设置handshake.feathers )。

A full tutorial how to set up sessions and using authentication can be found in the Using A View engine cookbook documentation.可以在Using A View 引擎说明书文档中找到如何设置会话和使用身份验证的完整教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM