Nodejs API - Authentication with Passport JWT strategy vs jsonwebtoken - node.js

I'm building an API using Nodejs/express and exploring different ways to implement authentication/authorization.
I've come across two packages which seem to do similiar things:
Passport with jwt strategy
and
jsonwebtoken
I really don't understand the difference between the two, but passport seems a lot more complicated. I know these kind of questions generally don't fair well on stack-overflow but i genuinely don't understand the difference between the two but it seems passport is generally better received? Can somone explain whether or not these packages truly accomplish the same goal or if there's a reason to use one over the other?
Thanks.

Passport is "Passport is authentication middleware for Node.js. Extremely flexible and modular" as they say it has lot's of strategies among that passport-jwt is one.
What Passport did is they brought all the different strategies together like google-auth Facebook-authentication local-authentication and so on .
jsonwebtoken is a strategy same as passport-jwt but it is individual & passport is group of strategies .
In my opinion you should learn passport as learning it you can use all kinds of strategies.A strategy is type of authentication .
Pardon me for my english hope you get it

Related

Which is more advisable to use in NodeJs, Passport or JWT and why?

I am new to Node Js and Currently working on a project with Express Js. I discover that User and can be achieved either through the Passport library or JSONWebTokens(JWT). So i was wondering which is the better option and why?
You can actually use them together. However, in short, passport is a module with many 'strategies' to help you authenticate users with multiple platforms. Passport-JWT is a strategy you could use as the auth strategy. This makes it easy when you use multiple ways to authenticate with your application. E.g. google, facebook, jwt, etc.

Question regarding passport.js' level of security

Just have some general questions about the level of security one can expect when using passport for an App's Authentication;
I am currently in the process of designing my first App using a MongoDB, Express, React and Node.js stack. Without having much prior knowledge about cyber security I have done quite a bit of research about authentication and what type of attacks can occur on my site. I have opted to use a cookie-based authentication system with the passport.js npm package and I have designed my /login route to require that the user's password and username first pass a passport.authenticate('local', ....) middleware setup before a session and cookie are created.
In order to persist the current user in my react app, I have a function which requests the server to provide it with the currently active passport session if there is one - and this seems to work as it will not maintain a login state if the user deletes the session cookie from their browser.
I am a bit skeptical of passport and I'm curious to know how easily it could be breached by someone who has a higher understanding of how it works, so the things I am wondering are several:
Is this type of authentication setup secure?
Are there any additional requirements that one must implement in order for passport to be a
legitimate method of authentication for an App?
Is using passport to authenticate users considered to be bad practice? Would showcasing an app that
authenticates users by using an npm package look bad if I were to showcase this application to a
potential employer?
I can share code if necessary to better illustrate my code setup, although I would prefer not to if at all possible. Any advice would be much appreciated, thanks!
TLDR:
Is passport.js a secure method to authenticate users? Is using passport.js for this bad practice?
Passport.js provides authentication, not security. It is fairly easy to misconfigure by following online tutorials, so take care - the tool is only as good as the hand it is in. To add security to passport, you will need at the very least three additional elements:
Strong state model for the session (or token) that does not leak private fields and uses argon2 for password hashing.
No mistakes on the front-end with CSRF or XSS.
Rate and buffer limitters on Node itself or, even better, on your reverse proxy.

Passport.js Strategies Comparison

I am confused about what Passport.js strategies to use in my web app made with:
Node.JS
Express
Angular
What are the differences between:
Passport-local,
Passport-http-bearer,
Passport-jwt?
Thank you so much!
the difference is authorization strategy use choose, nothing else. passport js will work same way for each of them. the simplest one is passport-local strategy

admin-on-rest with passport.js authentication?

I am wondering why I cannot find any AOR and passport auth code online? I found a ton of keystone and passport though... Is there a specific reason for that - the two should work well together, right?
You're right, there is no reason admin-on-rest would not work with passport -- however, there is a caveat:
It seems you are searching for a "passport + AOR" tutorial or guide, but one of the selling points of admin-on-rest is that it is truly agnostic to any authentication implementation. Therefore, you would implement a passport strategy of your choosing (jwt, oauth, http basic) within admin-on-rest's authClient.js
https://marmelab.com/admin-on-rest/Authentication.html

Is Waterlock production-ready?

I'm new to Sails.js and stumbled across JWT module called Waterlock. At a glance, it has local and social authentication which are what I'm looking for, which is nice.
However I wonder if this module is production-ready. The last update in Github was long ago and being unmaintained.
If it isn't, is there any production-ready JWT module which does similar to Waterlock available for Sails.js?
Go with Passport.js, Which is stable and if you stuck anywhere there is large community.
Authentication and Permissioning with Sails + Passport
Implement Passport.js authentication with Sails.js

Resources