What does passport.js do and why we need it?

后端 未结 2 1357
-上瘾入骨i
-上瘾入骨i 2021-02-03 23:35

I am not familiar with user authentication in Node.js, now I am trying to create a website with a login system. I have managed to make it work using the code snippets from the w

相关标签:
2条回答
  • 2021-02-04 00:05

    Passport is a middleware for express.js. It supports various login types, Basic, Token, Local (username, password), OAuth, OAuth2, etc. We can combine these to allow users to authenticate by signing in with Google, FB, or whatever service with very minimal amount of code. We can also use this to combine external auth services so users can choose to login with one of the selected Strategies, e.g. Google, Twitter. It's much quicker to use passport for authentication than to build one yourself from scratch. This is why we use passport. You don't need passport, it just makes developing quicker. Read more from there website => http://www.passportjs.org/

    0 讨论(0)
  • 2021-02-04 00:21

    To me it's unnecessary.

    It's not saving me any work. I have to write the configuration, the callback, and the user schema. To me, it's just easier for me to just write a middleware for that.

    And I don't see there is any security enforcement I am getting cuz I am writing my own verify callback anyway.

    So, I don't see any reason that I should use it.

    0 讨论(0)
提交回复
热议问题