socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Authorization in Socket IO

Open nambad opened this issue 15 years ago • 4 comments

I am pretty much confused with the authorization in socket io.

I want to implement some way in which i am able to know that the client is a genuine one and not a spoofer. How can i do that???

Can i transfer a self generated key along with the handshake or socket.connect method???

nambad avatar Nov 09 '11 06:11 nambad

Did you check out https://github.com/LearnBoost/socket.io/wiki/Authorizing ?

rauchg avatar Nov 09 '11 06:11 rauchg

Yeah.. I am working on it but it is pretty confusing.. I mean i am not able to figure out how to pass headers during handshake and also i am not sure whether it will make sure that the client is genuine and not a spoofer.

Currently, I took the index file of an already implemented socket io and node implementation, copied the data, created a local file, changed the host in javascript from "null" to the "original host", and it got connected!!

PS, I am new to node and socket io and js too!!!

nambad avatar Nov 09 '11 07:11 nambad

OK. I configured the origins parameter to accept the connections only from the required origins. Can anyone please confirm if there is anyway to modify the origin and access the data? I am just thinking in terms of security of the API which i am working on.

nambad avatar Nov 09 '11 11:11 nambad

Btw Can someone tell me how can i set multiple origins in the set origin parameter??

This is the part of output when i log the socket object

settings: { origins: 'http://192.168.100.92,http://localhost', log: true, store: { options: undefined, clients: {}, manager: [Circular] }, logger: { colors: true, level: 3, enabled: true },

And this is what I get when i try to connect warn - illegal origin: http://192.168.100.92

Wonder why it is happening like this. It should accept the connections from this origin. The code works fine when allowed with all origins

nambad avatar Nov 10 '11 07:11 nambad