I am trying to create an authentication app with nodejs passport-local. I am planning to use Cassandra as the db. Can anyone tell me how to integrate the two ? Sample code might be more helpful too
Passport gives you two hooks where you get to tell it how to serialise/deserialize a user. Basically, you will do something like this :
passport.serializeUser(function(user, callback) {
callback(null, user.id); //You will store the id in session
});
passport.deserializeUser(function(id, callback) {
var query = 'SELECT * FROM user_profiles WHERE id=?';
client.execute(query, function(err, result) {
callback(null,result.rows[0]); //Now we populate whole user using the id
});
});
P.S. The above code is untested and may not work. But it gives the basic idea about Passport integration.
You can use Cassandra Node.js Driver for your DB operations. Passport makes no assumption about how and where you store the data. You can use all sorts of DBs here - MongoDB, Cassandra or MySQL.. The key is using serializeUser and deserializeUser and loading the user object from underlying data store.
Robert Moran
Software Engineer with passion for Web
Passport gives you two hooks where you get to tell it how to serialise/deserialize a user. Basically, you will do something like this :
P.S. The above code is untested and may not work. But it gives the basic idea about Passport integration.
You can use Cassandra Node.js Driver for your DB operations. Passport makes no assumption about how and where you store the data. You can use all sorts of DBs here - MongoDB, Cassandra or MySQL.. The key is using
serializeUseranddeserializeUserand loading the user object from underlying data store.Passport Docs
Let me know if you have any questions!