Juggernaut / Socket.io and single-user channel subscription authentication

I'm new to Node JS and Socket IO, but I heard a lot of good things about them, so I wanted to take a look at them for use as a real-time notification system.

In my case, the user will open the socket to listen to notifications that are sent to the user - each user will open a connection with their OWN notifications, and not the "public" channel.

var jug = new Juggernaut; var channel = "/user/" + userId + "/notifications"; jug.subscribe(channel, function(data){ console.log("Got data: " + data); }); 

Thus, in almost all cases, this will be 1 user subscribing to 1 channel.

I have 2 problems:

  • All the Juggernaut examples I've seen include several clients subscribing to channel 1 - this makes me think that it is not intended to be used for messages 1-1.
  • Is there a way to add authentication so that only the message receives the message (IE, the newly registered user is the only one who can subscribe to their notification channel). If there was a way to transfer additional data for the subscription, it would probably be enough (the hash identifier of the user and use this as a token, maybe?).

Does anyone have experience with Juggernaut that may have come across this scenario before?

+4
source share
1 answer

All the Juggernaut examples I've seen include multiple customers subscribing to Channel 1.

What is the difference between many subscribers and one publisher subscriber?

Is there a way to add authentication so that only specified users receive a message

Sure. Require that the channel has authentication, and since it will be used by the user ID, then you already know what you need to protect it.

As for how to get juggernaut for authentication, it looks like you can host the host headers to handle this for you.

0
source

All Articles