Reputation: 1193
currently I am working on my project on raspberry pi, which is connected with intelligent house. I am using socket.io.System sending photos to my mail from monitoring system and I can open my doors from website. BUT there is no security, so now everyone can go to that page and do everything. What is the easiest way to secure my website with authentication on socket connection?
I would like to do something like that:
var io = require('socket.io')(server);
io.on('connection', function (socket) {
// here will be something, that require authentication
}
I am new to sockets, so I would like to avoid complicated solutions. I would like to add, that everything on that website works in realtime.
Thanks for any answers ;)
Upvotes: 0
Views: 404
Reputation: 702
Token-based Authentication with Socket.IO
Authentication in realtime frameworks can be challenging. Perhaps this is because the way these systems work is quite different from a regular web app. The risk of not correctly authenticating your sockets traffic is that you could end up sniffing information on other users streams. The socket server will not automagically know about the logged-in user, thus anyone could join any stream.
Upvotes: 1