-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Custom Headers not present in RLS #233
Comments
Current solution used: let loop = true
let now = new Date().toISOString()
while (loop) {
const { data, error } = await supabase
.from('test_realtime_rls')
.select()
.single()
if (data && !error) {
console.log('payload', data)
}
now = new Date().toISOString()
await wait(1000)
} It kind of self DDOS, but this is only used during onboarding of my users, so that will be like that until something better appear |
This is a followup to supabase/realtime#470 (comment). @riderx Yes, something like supabase/realtime#470 (comment). did you sign your own token and pass that in? |
@w3b6x9 that will require to my side to refactor the whole system who work already for normal query with header, the latest solution is not optimal but works. |
Ok thanks ! |
@w3b6x9 do you still not have any plans to support this? Would you be open to a PR for that? A warning in the supabase documentation to never use the request headers in RLS would be useful to avoid people designing the wrong solution only to find out later that it will never work with realtime. |
@NoRKin we're changing some things around regarding how we use RLS for authorization and this feature is planned to be added (this is a draft PR, the real implementation is yet to be implemented but it will be similar) |
@filipecabaco does this PR add support to RLS working with request headers in realtime? |
Also running into this issue. Is there a way to detect in postgres when a function is being called within the realtime context? Could at least add a temporary workaround for RLS rules. But I tried e.g. It's impossible to have a multi-account setup without headers. Only option seems to be issuing a new JWT per account, but that doesn't work well across tabs either. |
@lauri865 From the temp docs at github discussions... But just a guess. |
Just to reiterate, this is our setup: Now, the problem is with realtime, where it's not possible to set request headers. Which makes computing the RLS impossible, as we don't know which account is selected from the JWT. And before anyone suggests that we forge a new token, it's a strict requirement to be able to use different accounts across tabs. That would make the token refreshing logic quite complex, and another thing we would have to handle on our own without supabase. I think it would be great if On a side-note, the only way I could find to check if postgres function is called within the realtime context is the following – quite contrived, but essentially adding a custom claim to the subscription table, which then becomes accessible through
|
Bug report
Describe the bug
Custom header in Supabse SDK are not present to use in RLS as it is for query.
To Reproduce
Create a table
test_rls
with real-time and RLSAdd this RLS on ALL
Then set the SDK like that:
Now register a real-time listener:
And do insert with default value
Expected behavior
Insert should work, and a log payload should appear.
Where, in fact, only the insert works.
If I disable RLS and do insert again, the payload is logged.
System information
Additional context
I did try many solutions unsuccessfully:
supabase/realtime#470
supabase/supabase-js#553 (comment)
https://discord.com/channels/839993398554656828/1087461400647049377/1087461400647049377
This is coming from a use case of my product Capgo.
Where I created apikey ( access key) system for my users to use in the CLI of Capgo who is used in their CI/CD.
Using the login/password, seems not reliable to me in that case.
I know that made me an edge case of the SDK.
Hope I found an easy way to explain how to reproduce it.
The text was updated successfully, but these errors were encountered: