I'm looking for the simplest way to register and authenticate a user with the express library for node.js. I would like to store the users in a redis db.
I would prefer to use only express and not an additional library.
Also, once a user is authenticated. How should I carry out storing information pertinent to only 开发者_运维技巧that user? Perhaps the user's login would be the key in the redis db, and the value would be an array of other information? Or is that not a good solution?
I'm not familiar with authentication, but have some familiarity with node, express and redis so it hopefully won't be too much of a problem.
Any suggestions are welcome!
Check out EveryAuth. From what I've seen, it provides the most comprehensive solution, including support for passwords, OpenID, OAuth, LDAP, and so forth. You can use it and allow your users to login with a password or with many different online services, including twitter, facebook, linkedin, etc.
https://github.com/bnoguchi/everyauth
Here's a pretty decent video tutorial that integrates it with CouchDB:
http://nodetuts.com/tutorials/26-starting-with-everyauth.html https://github.com/pgte/nodetuts_26
I'm not familiar with authentication, but have some familiarity with node, express and redis so it hopefully won't be too much of a problem.
If you really want store passwords inside your database, which I don't think you should do(see below), you could have a quick look at TJ's example to do authentication.
I always think it is a bad idea to store passwords inside your (own) database. Stackoverflow author Jeff Atwood does have a very interesting article about this named OpenID: Does The World Really Need Yet Another Username and Password?. I would advise you to use systems like OpenID(facebook-connect, etc) just like stackoverflow.com is doing. A good openid library is available, which is very easy to use.
connect-auth is a good choice for third party auth.
If you are planning to write your own, see this thread for an example
精彩评论