supercobra
(Daniel Guermeur)
23.Июль.2021 15:48:22
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 лайк
pfaffman
(Jay Pfaffman)
24.Июль.2021 01:20:40
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)
24.Июль.2021 05:56:37
3
Can you expand a bit more about your use case? What are you trying to build?
1 лайк
supercobra
(Daniel Guermeur)
28.Июль.2021 18:15:26
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 лайка