-
-
Notifications
You must be signed in to change notification settings - Fork 319
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 connection failing when custom JWT is used #470
Comments
@gouthamraj-r how did you set up self-host supabase? |
@w3b6x9 This seems to be a bug in supabase-js. I made some changes to it and now its working fine for me. Here's a PR for it - supabase/supabase-js#704 |
@w3b6x9 It doesn't solve my problem, still getting a connection error. Sending custom jwt through headers causes this issue. I tried sending anon key and it works fine. (note: my custom jwt is also signed with the same supabase secret key as anon key) |
@w3b6x9 I'm able to fix this by doing this |
This only works for hosted Supabase Realtime. For self-hosters, you can use |
@w3b6x9 thanks a lot for the sharing. That has worked super well, right now, I'm making an onboarding command who will watch a table change. export const createSupabaseClient = (apikey: string) => createClient<Database>(hostSupa, supaAnon, {
global: {
headers: {
capgkey: apikey,
}
},
realtime: {
headers: {
apikey: supaAnon,
},
params: {
apikey,
capgkey: apikey,
},
},
}) It seems my token is not present in RLS check with real-time request. (current_setting('request.headers'::text, true))::json ->> 'capgkey'::text) And this work with the rest of the SDK only in Real-time, it doesn't |
@riderx since |
It would be like ? ((current_setting('request.jwt.claims'::text, true))::json ->> 'capgkey'::text) |
Even with that don't work, I tried to find in the logs the issue but i could locate in the log my issue, do you know how i could inspect what's happening ? |
In the CLI my users use the anon key with the capgokey to check they right, @w3b6x9 you are sure jwt.claims will help me ? |
Bug report
Describe the bug
I'm using supabase self-hosted and auth0 for my authentication instead of the default authentication provided by supabase. So I'm signing my auth0's payload with supabase secret and sending it in headers.
I also enabled the RLS policy on my table. Using the above headers I'm able to query my database. Now I wanted to enable real-time on my table. But when I try to create a subscription with my custom headers, the Realtime web socket connection throws an Authentication error. When I don't send the custom JWT in the header, it works fine but I need my custom JWT's payload to be stored in the subscription table. realtime so that I can use it on my RLS Policy. What should I do to fix this?
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
I want a realtime websocket connection to be created using my custom JWT and the payload of my custom JWT should be inserted into the claims column of 'realtime. subscription' table.
System information
The text was updated successfully, but these errors were encountered: