socket.io authentication
Hi! I recently discover the amazing work of better-auth, so first line to adress a huge thanks to all devs and constribs. Cheers to you all!
I recently introduced better-auth as the authentication technique for a web app I'm building. To make it short, the app is essentially a real-time chat app, with mainly users and a single automated client. To ensure proper live chat, I introduced socket.io in the server, and currently am looking into authentification. I have found a way to authenticate the automated client through API key, but what would you recommend as a solution to authenticate regular users? I have a custom server.js for socket server initialisation, in which I can make the token verification. I also thought to implement jwt, and have already set up the verification method in the server but I am struggling to implement the socket initialisation on client side with the jwt as part of the init request.
Have any of you faced similar issue before? Thanks! 😊
2 Replies
One-Time Token Plugin | Better Auth
Generate and verify single-use token
Okay, I'll give it a look. Didn't notice it earlier. Thanks 😉
I think more broadly the issue I am facing is that I cannot manage to properly import the auth.ts file in my server.js. I am quite new to typescript and still discovering much of it, but I think there probably the mix of js and ts is doing no good