0.1.1 • Published 10 years ago

jwtauth-socket v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

jwtauth-socket

Authenticate Socket.IO Connection using JSON Web Tokens (jwt) and the node-jwt-simple library

Client Side:

Connect socket with adding a token as a query parameter:

var socket = io.connect('http://localhost', {
  query: 'token=abcdefghijklmnopqrstuvwxyz

});

Server Side:

var server = http.createServer(app);
var io = require('socket.io').listen(server);
io.configure(function() {        
    io.set('authorization', jwtAuth.auth('your jwt secret'));
});    


io.sockets.on('connection', function(socket) {
    console.log('decoded', socket.handshake.decoded); // decoded is your decided token
});