Is there a way to query if authenticated user sati...
# help
l
Is there a way to query if authenticated user satisfies the RLS checks without sending any data? As in, a way to first check permissions e.g. for INSERT, and then later send the data when user is ready to do so.
n
Hello ! This thread has been automatically created from your message in a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
🆕 Checking if authenticated user satisfies RLS check
l
Say if I wanted to do a permission check based on the RLS clause in my authentication handler in my backend before doing the actual insert, would I be able to do this?
g
I can't think of a way to check the actual RLS without doing the insert as each policy could be different (insert,read,update) and for possibly multiple tables depending on the complexity of your policies
n
Checking if authenticated user satisfies RLS check
l
Yeah, I guess a way to do this would be to maintain a separate table that contains permissions for each entity for the user.. Then I could just query that table and check if the user can do an update/insert/whatever
Which is kind of awkward 😅
g
Yeah, same with writing an RPC function just to simulate the RLS WHERE clause being true. Sort of pain to maintain.
l
Only reason why I'd like to do this is because I'd like to use the ORM I have in my backend instead of directly using Supabase client in the browser.
Data handling is much nicer and smoother with the ORM
s
When building an application this way the permission handling is normally handled in your codebase than in the database. The database would still hold the roles and permissions but the logic to do the checking would happen in your code itself.