Authentication of SocketCluster connections with Passport.js
Passport.SocketCluster is a SocketCluster middleware that can be used to authenticate socket connections with Passport.js.
Installation
npm install passport.socketcluster
How it works
It plugs into the socket handshake process and parses your Express session cookie associated with the request. If the authentication was successful, you will receive a Passport user object that you can store in a SocketCluster socket session or any other store for later use.
Usage
1 | //worker.js |
You can later retrieve a user object in your socket server code this way:
1 | module.exports = function(worker) { |