You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working with Realtime recently and needed a way to safetly listen to all events on a node.js server.
Here I want to explain my problem and solution for future reference.
Problem
By default SECURE_CHANNELS is 'false'. That means everybody with the anon-key (which is public) can listen to ALL data changes, since Row-Level Security is available for Rest only. That's for sure not what we want...
With SECURE_CHANNELS is 'true', we need to authenticate with a JWT.
However, for my use case I didn't want to authenticate with a particular user, since I wasn't listening in the browser, but on an node.js server. I wanted to listen to everything.
Since my application doesn't require any realtime listening on the client I'm now using the following approach:
Solution
I'm now using the ACL Kong Plugin to allow Realtime usage only for the service-key.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey everybody,
I've been working with Realtime recently and needed a way to safetly listen to all events on a node.js server.
Here I want to explain my problem and solution for future reference.
Problem
By default SECURE_CHANNELS is 'false'. That means everybody with the anon-key (which is public) can listen to ALL data changes, since Row-Level Security is available for Rest only. That's for sure not what we want...
With SECURE_CHANNELS is 'true', we need to authenticate with a JWT.
However, for my use case I didn't want to authenticate with a particular user, since I wasn't listening in the browser, but on an node.js server. I wanted to listen to everything.
Since my application doesn't require any realtime listening on the client I'm now using the following approach:
Solution
I'm now using the ACL Kong Plugin to allow Realtime usage only for the service-key.
So I've adjusted the kong.yml:
Don't forget to add "acl" to the Kong plugin lists in the docker-compose.yml and kong/Dockerfile.
Restart the services via: docker-compose up -d --force-recreate --build
Now the anon-key can't connect to the realtime socket anymore, but the service-key can. ;)
Hope this helps somebody! If you have any questions or ideas, just let me know.
Beta Was this translation helpful? Give feedback.
All reactions