I have an application in which each user should receive notifications related only to themselves.
To do this, I created a unique channel name for each user. I subscribe to this channel when a user logs in from a browser using javascript.
pubnub = PUBNUB.init({ subscribe_key : '<subscriber-key>' }); pubnub.subscribe({ channel: "<unique-channel-name>", })
My question is: if someone gets the name of a unique user channel, can he set up his own pubnub client and receive notifications without any permission? Basically, all that protects my user data is the channel name and subscriber key, which are publicly available in the source code of the page . I looked at the pubnub access manager, but it suffers from the same problem, right? If someone opens the source code and copies the auth key, can they configure their own client and receive messages?
Edit: Additional Information
I generate and save the channel name for each user during registration. This name is a random UUID, for example, "7304cd62-9ba2-4842-98d8-8a5c8e561275". When I want to notify a user who, say, received a friend’s request, I pull the channel name from the database and post a notification. Whenever they log in, the displayed page uses Ruby to enter the name of its channel, and my subscriber key is in a hidden field that javascript uses to initialize pubnub.
<%= my_pubnub_subscriber_key %> <%= current_user.channel.name %>
In this case, using Access Manager will mean that I will need to save the authorization key in addition to the channel name and allow the key to read the channel.
John - john-channel - john-key-authorizing-read-on-john-channel Jane - jane-channel - jane-key-authorizing-read-on-jane-channel
The render page will have three fields for initializing pubnub:
<%= my_pubnub_subscriber_key %> <%= john-channel %> <%= john-key %>
The original problem remains. If Jane goes to John’s house, the source code of John’s main page opens, copies 3 keys, returns home and creates her own client, she can sign up for John’s notifications. I don’t know if the recipient of my notifications really registered or just copied the keys.
I believe that to protect against this possibility, I just have to regularly update the channel name or auth key, for example, when the user logs out or daily?