Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling sessions in nodejs Passport.js

I just discovered about Tokens for authentication which allows session/stateless servers and starting out with MEAN. Looks amazing.

Right now, I'm using Passport.js to authenticate users (via Email, Facebook, Google,...), which stores information into the server session like all the tutorials say:

 // required for passport
    app.use(express.session({
        secret : 'superscret',
        expires: new Date(+new Date + settings.session.sessionTimeout),
        store: new MongoStore({})
    })); // session secret
    app.use(passport.initialize());
    app.use(passport.session({}));

Is it possible to still use Passport.js but instead of storing the session, sends back a token to monitor if the user has access.

Question: How can disable sessions for passport? (I know how to send the token and listen for it).

like image 463
denislexic Avatar asked Sep 28 '22 07:09

denislexic


1 Answers

I suggest using satellizer, de-facto standard library for token based authentication in AngularJS. It implements token based authentication only and is much easier to get working for your purposes. It also has good server examples, including Node.js server example.

like image 72
krl Avatar answered Sep 30 '22 05:09

krl