supercobra
(Daniel Guermeur)
July 23, 2021, 3:48pm
1
Hi there,
I understand message bus publishes to target users as per the documentation:
When you publish a message you specify who is allowed to see it:
# only user id 100 will get secret santa
MessageBus.publish('/secret', 'santa', user_ids: [100])
The middleware will not distribute messages to users who are not allowed to see them
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
pfaffman
(Jay Pfaffman)
July 24, 2021, 1:20am
2
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.
sam
(Sam Saffron)
July 24, 2021, 5:56am
3
Can you expand a bit more about your use case? What are you trying to build?
1 Like
supercobra
(Daniel Guermeur)
July 28, 2021, 6:15pm
4
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.
2 Likes