Message bus: channel subscription permission

Hi there,

I understand message bus publishes to target users as per the documentation:

However, I am wondering if there is a way to check permission when a client tries to subscribe to a channel, something like this:

MessageBus.on_subscribe('/bank_account_123') do
   if current_user.bank_account == 123
      # subscription granted
   else
     # subscription denied
   end
1 Like

I’m not an expert here, but I think you want to control access on the publishing end where you’re sending stuff to the bus, not on the watching side.

Can you expand a bit more about your use case? What are you trying to build?

1 Like

We are retooling one of our apps and replacing Action Cable with Message Bus. Our current pattern was to check permission on subscribe but now I think we can use Message Bus the way it is intended. So we are good. Message Bus is very well done btw. :slightly_smiling_face:

2 Likes