-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Realtime unable to connect with custom token #1113
Comments
This could be because of #1114 |
@antonio-bluco can you see my comment here #1114 (comment) and try what I suggest (i.e., use |
Hi @barrownicholas , thanks a lot for your message! Unfortunately this seems to be unrelated - I started supabase locally with that version but nothing changed. |
are you using realtime locally or in a hosted project? If locally could you provide the logs from realtime and if hosted could you open a support ticket so we can check your project reference directly? |
Hi i am suddenly having the same problem after it working for a while and can't figure it out. On hosted |
@fullstackwebdev could you provide more details? |
my problem: I get no records for INSERTS or UPDATES when RLS is enabled If I disable RLS, I get all records, but my table is wide open to the world. I believe the issue is that on the postgres server receving the auth token it is not correctly setting the authenticated role in the SQL connection. In postgraphile I can showyou where this is done, however, I cannot find it in your codebase. Or it could be complete unrelated issue causing my problems. Can you please assist me resolving this? Steps to investigate? I believe my theory is correct. |
Got it, can you open a ticket so we can follow up with your project reference? That will help us debug a bit better what could be happening. We do things differently since we do that impersonation using walrus which is a different way of fetching WAL changes with RLS applied. |
supabase/supabase#29542 Would this work? |
@fullstackwebdev no as I will need your authorization to work in your project ref. Use this link : https://supabase.com/dashboard/support/new but do keep that ticket open as we can use that to discuss and share solutions specific problem after the fact 👍 |
Bug report
I am unable to connect to realtime using custom token. I can connect to the table (so RLS works fine), but not to realtime.
Describe the bug
I am unable to have realtime work as expect, even after following all the docs I could find, specifically this and this.
On the server, I authenticate the user, then I create a JWT token:
I then pass this token to the client component, and use it as such:
Then I go to my table, I enable Realtime for that particular table
, and I enable RLS with the condition
USING (auth.checkMyUser() = "userId")
where the checkMyUser function is defined as
I have checked that the RLS seems to work correctly, because if I do in the client component:
I see the correct values, which means that the token has been correctly created and parsed by the RLS policy.
However, I can't seem to get any events from the realtime connection created as such:
What is more is, if I change the RLS to allow access to anyone (
USING true
) , then the realtime connection works and it shows the right results. So it seems to be something wrong in the way the access token is passed to the realtime library, but I have no idea what - all the docs seem to suggest usingsupabase.realtime.setAuth(token)
or perhapssupabase.realtime.accessToken=token;
, but neither of these worked.Can someone help me here? How are we meant to pass custom tokens for authentication?
While we are at it, is there any way to debug this, instead of just trying to guess what the problem is?
The text was updated successfully, but these errors were encountered: