0

I've been trying to use Passport / Express / Node.Js combination to handle user authentication, but it proved to be too difficult.

All the tutorials out there use MongoDB (which I don't want to use as I have Neo4J database that I want to use instead) and the examples on Passport's passport-local are not really suitable to me, because I already used a local authentication strategy from Node.Js in Action book - see on my github and I don't understand how to swap it over to the new one.

I can't seem to find any good, easy-to-use, step-by-step introduction for the beginners like me. It doesn't have to be Passport, but it has to be something, which would enable me to login users via a local strategy, as well as Facebook and Google.

It would also be good to know how it could be implemented without disrupting what I already have, so any help with this would be very much appreciated....

1
  • 2
    Which part of implementing passport in express was too difficult? Commented Mar 10, 2014 at 14:20

2 Answers 2

1

Passport is going to be your best/easiest choice because a lot of other people use and it has a lot of pre-made strategies as you mention.

The tutorial use of Mongo is just an example. You can make use of any asynchronous connection that you want (mysql, neo4j, read the file system, etc) so long as you construct an object which represents your user and call the done function that is given to you.

One of the greatest benefits of using Passport is that you CAN switch the strategy involved without disrupting anything else. If you are simply swapping out the data storage behind the LocalStrategy then all you should have to change are the authorize and deserializeUser functions such that they access your new DB. If the structure of the User object changes then you'll also have to tweak your serializeUser function to return whatever the identifying token/value is.

Sign up to request clarification or add additional context in comments.

Comments

0

You could take a look to a very simple user authentication snippet created by Charles Daniel: https://gist.github.com/charlesdaniel/1686663

Basically the username and password are harcoded in the sever code (hack/thegibson) but you can use it as a start to build something more meaningful

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.