supercobra
(Daniel Guermeur)
23 يوليو 2021، 3:48م
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، 1:20ص
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، 5:56ص
3
Can you expand a bit more about your use case? What are you trying to build?
إعجاب واحد (1)
supercobra
(Daniel Guermeur)
28 يوليو 2021، 6:15م
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)