简体   繁体   English

使用像passportjs这样的用户身份验证框架还是仅仅使用普通的node.js更常见?

[英]Is it more common to use an user authentication framework like passportjs or just plain node.js?

As the tile indicates, I am wondering as to whether正如瓷砖所示,我想知道是否

  • using a user authentication framework like passportJS is the most popular option for user authentication implementation (excluding using any third party services)使用像passportJS这样的用户认证框架是最流行的用户认证实现选项(不包括使用任何第三方服务)

  • or whether using builtin Node.js functions is more standard.或者使用内置的 Node.js 函数是否更标准。

The value of passportJS is that is supports many dozens of authentication strategies with various add-ons so you can pick up pre-built code for multiple authentication strategies that all work within one overall authentication model. passportJS 的价值在于它支持数十种带有各种附加组件的身份验证策略,因此您可以为多个身份验证策略选择预构建的代码,这些策略都在一个整体身份验证模型中工作。 So, your app could code for passportJS and automatically support as many of the various strategies that passportJS supports as you want.因此,您的应用程序可以为passportJS 编写代码,并根据需要自动支持passportJS 支持的各种策略。

If you've seen websites that let you login with Google, Facebook, Twitter or your own custom username/password, then this is a lot easier to implement if you use an authentication framework like passportJS that already links all these login strategies into one model rather than you writing your own code to hook up to all those different services and probably writing your own internal API to hide the inner details of whatever login service is being used.如果您见过允许您使用 Google、Facebook、Twitter 或您自己的自定义用户名/密码登录的网站,那么如果您使用像 PassportJS 这样的身份验证框架,它已经将所有这些登录策略链接到一个模型中,那么实现起来会容易得多而不是您编写自己的代码来连接所有这些不同的服务,并且可能编写自己的内部 API 来隐藏正在使用的任何登录服务的内部细节。

On the other hand, if you are only ever going to support one authentication model then there's far less reason to use passportJS as you can just implement that one model natively and you can probably pick up a nodejs module for that one model to save you some work.另一方面,如果您只打算支持一个身份验证模型,那么使用passportJS 的理由要少得多,因为您可以在本地实现该模型,并且您可能会为该模型选择一个nodejs 模块来为您节省一些工作。

For my own work, I chose to use passportJS even when I was only starting with username/password because I wanted the flexibility to easily support other login services without having to rearchitect anything later.对于我自己的工作,即使我只从用户名/密码开始,我也选择使用passportJS,因为我希望能够灵活地轻松支持其他登录服务,而无需稍后重新构建任何内容。 I had to learn how to use passportJS, but I felt that was a small price to pay for the flexibility going forward to add other authentication models.我必须学习如何使用passportJS,但我觉得这是为了增加其他身份验证模型的灵活性而付出的代价很小。 You will obviously need to make your own choices in this regard, based on your own goals and your own thinking about what the future of your app might include.您显然需要在这方面做出自己的选择,基于您自己的目标和您自己对应用程序未来可能包括的内容的思考。

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

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