socket.io-passport

Passport middleware for Socket.IO

socket.io-passport

Passport middleware for Socket.IO.

$ npm install socket.io-passport

Use with socket.io-bundle.

var passport = require('passport');
var bundle = require('socket.io-bundle');
var ioPassport = require('socket.io-passport');
var server = require('http').Server();
var io = require('socket.io')(server);
 
passport.deserializeUser(function(iddone) {
  done(null, {id: id, name: 'foo'});
});
 
io.use(bundle.cookieParser());
io.use(bundle.session({secret: 'my secret'}));
io.use(ioPassport.initialize());
io.use(ioPassport.session());
 
io.on('connection', function(socket) {
  console.log(socket.request.user);
});
 
server.listen(3000);

MIT