Authenticating Socket.io Connections
An Experience of Trials and Tribulations
I’m currently working on the backend infrastructure for GarbageBytes, a robotic trashcan company (yes, sounds weird, but trust me, it’s really cool). In the process, I had to delve into the world of sockets for real time data transmission from robot to server and server to user.
However, I ran into the problem of authentication. I found this, an unmaintained library for authentication using JWT. I use JWT tokens, so this seemed interesting, but I found the documentation lacking. Anyways, I made a little solution to do so, code below in case you’re interested.
Pretty straight forward. Of course, if you want to use JWT tokens in the middle to connect with a user that’s already authorized, feel free to do so.
Questions? Comment and I’ll get back to you :).