Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Realtime update events won´t work with auth.uid - checking RLS policy! #68

Open
BurSari92 opened this issue Jul 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@BurSari92
Copy link

Hi guys,

I think I found an really annoying bug.
The code below is only working if I change the RLS policy inside supabase to "read access for everyone".
But if i make a standard authentication check policy like "(auth.uid() = user_id)" it won´t work and I won´t get any update informations on client.

Database reading with the "standard auth policy" is working fine, like "read access for everyone policy" does btw.
I think the client variable is not passing some auth informations to server probably?

Before executing the function below, the user signes in of course.

var client : RealtimeClient
var channel : RealtimeChannel

func _getChangesFromServer():
	client = Supabase.realtime.client()
	client.connected.connect(Callable(self, "_onConnectedToFriendChat"))
	client.connect_client()

func _onConnectedToFriendChat():
	var userID : String = userData[0]["id"]
	
	channel = client.channel("public", "friends", "user_id=eq." + userID)
	channel.update.connect(Callable(self,"_onFriendChatUpdate"))
	channel.subscribe()

func _onFriendChatUpdate(old_record : Dictionary, new_record : Dictionary, channel : RealtimeChannel):
	print("New Record updated from ", JSON.stringify(old_record), "to ", JSON.stringify(new_record), " on ", channel.topic)

For now I am using a filter to get only data which the user should have access to ("user_id=eq." + userID) but security-wise it´s a mess..

Hope someone could help out!

@BurSari92 BurSari92 added the bug Something isn't working label Jul 19, 2023
@ghost
Copy link

ghost commented Sep 26, 2023

The update from this library does not work in general

@MaxKablaam
Copy link

I'm having the same bug. If I put my tables RLS read access to public, the realtime works. If not, I get no notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants