这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@BurSari92

Description

@BurSari92

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions