Closed PavelKv closed 3 years ago
Hi All,
This is more of a question than issue, I would like to use JWT to authenticate calls on Hapi with socket.io however I am not sure how should I validate token. Here is server part of socket.io on HAPI server:
const io = SocketIO.listen(server.listener); io.use(function(socket, next) { let token = socket.handshake.query.token;
next();
}); io.sockets.on('connection', (socket) => { socket.emit('msg', 'welcome') });
I could just pass token to validate function for hapi-auth-jwt2 but I would have to decode it first, would this be a correct approach?
Thanks, Pav
Socket.io auth is a legitimate use case. If anyone still needs/wants it, we would gladly accept a PR. Thanks. 👍
Hi All,
This is more of a question than issue, I would like to use JWT to authenticate calls on Hapi with socket.io however I am not sure how should I validate token. Here is server part of socket.io on HAPI server:
const io = SocketIO.listen(server.listener); io.use(function(socket, next) { let token = socket.handshake.query.token;
}); io.sockets.on('connection', (socket) => { socket.emit('msg', 'welcome') });
I could just pass token to validate function for hapi-auth-jwt2 but I would have to decode it first, would this be a correct approach?
Thanks, Pav