Denzo
01/12/2022, 2:36 PMSELECT, INSERT and UPDATE to be publically accessible with the Anon key, but only if the user knows either the deviceId or userId. I can't use auth().id because I want the API to be accessible even for users that have not yet registered. I just want people to prevent from querying the entire DB. How would I implement this using a policy?Scott P
01/12/2022, 3:30 PMinsert , update, delete and select) with the policy value simply set to false. This will prevent all operations against the table for anyone except admin or secret key, or postgres functions
- Create some postgres functions which accept userId and deviceId parameters which will perform the query.
If you specify SECURITY DEFINER for the function when creating it, it will be able to bypass RLS.
Then, you would call those functions with .rpc()Denzo
01/12/2022, 3:36 PMgaryaustin
01/13/2022, 2:20 AM