All Questions

Filter by
Sorted by
Tagged with
5 votes
2 answers
891 views

Only allow read if user has exact document id postgresql row level security/supabase

Is there a way for a user to only be able to read a document only if they have the exact document ID? I want to avoid creating users, so the only security is a random guid saved in browser memory - ...
Rune Jeppesen's user avatar
2 votes
1 answer
877 views

Row-level-security dual join

I have three tables journeys id user_id ... sections id journey_id ... stops id section_id ... I want to use row level security to make sure that a user can only insert a stop if the uid()...
hoan's user avatar
  • 1,327
2 votes
2 answers
2k views

Row-level-security based on relation table data

I am getting into Supabase and to practice I am making a suuuper simplified website-builder. However I am having troubles with the row-level-security policies. I have three tables: user → with users' ...
st_phan's user avatar
  • 824
2 votes
1 answer
249 views

how to use supabase RLS with "in" and "select" without having to provide unrestricted RLS access to the joined tables

I am trying to set up simple RLS on my supabase tables. I enabled RLS on all tables, then added this policy to a table I wanted to select from: (project_id IN ( SELECT projects.id FROM projects)) ...
Nathan Tew's user avatar
2 votes
0 answers
3k views

Why is supabase update not working for me?

I am trying to update a user's name in the profiles table. This command works when i disable rls on the table but not when it is on. When the function is called the error is null, data is just an ...
Jaksa's user avatar
  • 43
2 votes
1 answer
2k views

Designing a Multi-tenant SAAS Database with Postgres RLS

I want to design a multi-tenant SAAS database with PostgreSQL and RLS. I want to be able to host all users and the tenants in the same database and isolate their data with RLS. In my use case it makes ...
Ghost's user avatar
  • 45
1 vote
1 answer
2k views

Applying a row-level-security policy on a view [duplicate]

I'm a bit new to the whole Supabase thing. I'm trying to apply a policy to a view that I created. I'm not sure if it's even possible but I can't see why it wouldn't be. I don't think that this ...
Alb's user avatar
  • 1,101
1 vote
2 answers
3k views

Supabase update with row level policies

I am not able to update a row which has role level policy enabled My table has row level policies on insert and update as follow : create policy "Allow individual insert access" on public....
Olivier's user avatar
  • 128
1 vote
1 answer
720 views

How can I dump or export row level security policies from a Postres database?

I'm using Supabase and defined several row level security policies in their UI. Now I'd like to download or export all the policies to review and/or edit them. I found documentation on querying the ...
Dave's user avatar
  • 3,231
1 vote
1 answer
149 views

Supabase realtime - RLS to only allow delete if url /xyz matches xyz in DB column

I have a table "boards" with a column "edit_link" which is a randomized string I want users who visit the page /edit/xyz to be able to only update and delete the row where ...
AndersD's user avatar
  • 126
1 vote
1 answer
932 views

Possible to restrict PostgreSQL security definer function to RLS use?

I am using RLS (Row Level Security) with supabase.io for a "serverless" application. I have to use various security definer functions for RLS policies. These are still callable through ...
AJP's user avatar
  • 27.4k
1 vote
1 answer
373 views

can't enable row level security using sqlalchemy engine

I have my sqlalchemy engine setup as such: DATABASE_URL = ( f"postgresql://postgres:{PG_PASS}@db.blabla.supabase.co:5432/postgres" ) engine = create_engine(DATABASE_URL) And I use the ...
hud's user avatar
  • 19
1 vote
2 answers
401 views

Supabase RLS policy turns into recursive loop when selecting same table

I am trying to retrieve data from a table, bit it is getting stuck in an infinite recursive loop due to my RLS policies, which look at the same table. I have a table called 'community_members' that ...
Koen's user avatar
  • 13
1 vote
0 answers
163 views

How to check if a user is a member within an organisation within a members RLS policy with Supabase

I'm trying to write a SELECT RLS policy for a members table within Supabase. The policy should only reveal members that are in the same organisations as you. Each row in the members table represents a ...
Alexander Hunter's user avatar
1 vote
1 answer
3k views

406 JSON object requested, multiple (or no) rows when RLS is enabled on Supabase

I have looked at various solutions on StackOverflow, github issues in supabase, supabase/postgrest-js, postgRESTPostgREST/postgrest, and searched the Discord as well. But none of the solutions have ...
Scott Yu's user avatar
  • 145
0 votes
1 answer
151 views

Row Level Security with Common Table Expression

Given this schema: CREATE TABLE posts ( id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), title text NOT NULL CHECK (char_length(title) > 2), author uuid NOT NULL DEFAULT auth.uid() ...
Jonathan's user avatar
  • 4,393
0 votes
1 answer
355 views

Supabase PSQL row level security policy for update vs insert

I have a workspaces and profiles_workspaces (cols = worspace_id, profile_id) table and want to implement a soft-delete, so workspaces has a is_deleted boolean column. So for deletion I'd just do an ...
Killerpixler's user avatar
  • 4,298
0 votes
1 answer
142 views

How to safely manage normalized permissions in Postgres with RLS

I like using a separate table to manage RLS permissions, but normalization creates a challenge when inserting new data. The general idea is that no access control logic is built into the items table, (...
cazzer's user avatar
  • 1,746
0 votes
1 answer
1k views

How to specify in supabase a field should only have default value?

I'm making a basic chat app using supabase. I've figured out how to make it so users can only create/edit their profile and send messages from their profile using RLS, by checking if their id matches ...
Anton's user avatar
  • 639
0 votes
1 answer
536 views

how delete row with PostgreSQL RLS - supabase

i tried to create policy for delete rows older then '10 seconds' CREATE POLICY "DELETE" ON "public"."pool" AS PERMISSIVE FOR DELETE TO public USING ((created_at < (now(...
Selcukusu's user avatar
  • 195
0 votes
0 answers
12 views

How do I use Supabase Realtime database with RLS and a custom JWT?

I am having trouble getting realtime data from my Supabase database when using Row level security (RLS) and a custom JWT. When getting data from the database normally things work as expected, but when ...
Andrew Bloyce's user avatar
0 votes
0 answers
14 views

Row level security on select statement to select multiple rows from two tables

I have only used Postgres briefly, so still trying to learn. I have 3 tables, "users", "teams" and then to connect users to multiple teams "users_teams". users ...
PowerPlower007's user avatar
0 votes
0 answers
4 views

Implementing Row Level Security with Dynamic Permissions in Supabase for Role Management

Imagine two tables: Website name type id int Website Contributor name type description account_id uuid FK to supabase's authenticated users table; auth.uid() website_id int FK to website role ...
WQYeo's user avatar
  • 3,986
0 votes
0 answers
30 views

supabase postgress roles error in flutter

in supabase after creating role 'adminRole' then granting the role to an email through update auth.users set role = 'adminRole' where email='my email'; i checked the table and it did update. then ...
enn_kh's user avatar
  • 1
0 votes
0 answers
35 views

Proper way to query table for RLS

I'm sure this is a common question but I cannot find the answer. I want to query a separate table called users and check if they have property is_moderator = true. (EXISTS ( SELECT 1 FROM users ...
OMGItsRob's user avatar
  • 105
0 votes
1 answer
74 views

supabase database functions and RLS

I am using supabase and i am trying to accomplish one thing. I have a table called "customers", and it's like this: customer_id, first_name, last_name,....., profile_id (from the profile ...
J0mk's user avatar
  • 133
0 votes
1 answer
179 views

supabase / PostgreSQL RLS Rule leads to "infinite recursion detected in policy for relation \"profiles\""

I am currently familiarizing myself with Supabase and Postgres and RLS-Rules. But these rules lead to an error: response 400 "infinite recursion detected in policy for relation "profiles&...
Henner's user avatar
  • 1
0 votes
0 answers
39 views

Update failing because of RLS for SELECT [duplicate]

I have a table Account(id, status, owner) with the following RLS policies: For SELECT: CREATE POLICY "Allow users to select active accounts" ON "public"."Account" AS ...
byteSlayer's user avatar
  • 2,019
0 votes
1 answer
69 views

supabase RLS policy using "in" always fails

I'm setting up RLS for a table in supabase, and querying it from my React app. Using this policy works: (project_id = 8) However, this always fails: (project_id IN ( SELECT projects.id FROM projects))...
Nathan Tew's user avatar
0 votes
1 answer
22 views

define row level security poliicy for supabase superadmins

Trying to create a policy in supabase to allow super admins to make new organisations. What am I doing wrong here? Update: the organisations_members table has the columns user_id and role. I want to ...
Sventies's user avatar
  • 2,600
0 votes
0 answers
155 views

Supabase policy results in empty array after executing RPC function

In order to activate RLS for my project, I am using the following Supabase policy for my table "quotations": (customername = ((auth.jwt() -> 'app_metadata'::text) ->> 'customername':...
Kristian's user avatar
0 votes
0 answers
116 views

nested queries with supabase rls

I use supabase as a db, and I would like to enable rls, but I worry about nested data: Say I have the following tables, nested in this way: Orgs Users Spaces Projects Notes ...
Sventies's user avatar
  • 2,600
0 votes
1 answer
532 views

Conditional INSERT in supabase Postgres RLS

The premise of my question is simple, I have three tables : users (user_id) records_users (record_id, user_id) records (record_id, created_by) I would like users to be able to INSERT into the ...
Fredaroo's user avatar
  • 349
0 votes
0 answers
48 views

Restrict SELECT operation to users within the same organisation

I've created an application where users must register using an organisation key (a uuid that is created when a new organisation is added to the organisations table). The registration of a new user ...
ChaddRobertson's user avatar
0 votes
1 answer
180 views

How can i use hCaptcha verification to protect a table in supabase?

In supabase: I have a table named "ratings", this table have three columns named; "rating", "review" and "name", the "ratings" table is basically ...
Amirhosein Nikfallah's user avatar
0 votes
0 answers
211 views

NextJS - Supabase RLS Failing

I have the following data model: I want to run the following query inside my getServerSideProps function: const { data, error } = await supabase.from('user_profile').select(` subscription ( ...
Sam's user avatar
  • 1,180
0 votes
1 answer
2k views

Some tables give 'new row violates row-level security policy' error but some do not

I have created a new login role and assigned permissions to it: CREATE ROLE myuser LOGIN PASSWORD 'password'; GRANT SELECT, INSERT, UPDATE, DELETE ON customer TO myuser; GRANT SELECT, INSERT, UPDATE, ...
Brad Mathews's user avatar
  • 1,717
0 votes
1 answer
38 views

Connection between SELECT policy and PATCH API? PATCH request doesn't work due to SELECT policy

There is this table "customer" and it has "is_deleted" column. I did to use it for soft deletetion. And I set policy like below so that I don't have to add is_deleted = false ...
jooyeon yi's user avatar
0 votes
1 answer
328 views

Row level security issues on insert

I am trying to create an RLS in supabase for an initiative_categories table since when the service creates a new initiative it calls another function to create a new record in the ...
Richi's user avatar
  • 478
0 votes
2 answers
482 views

How do I cap number of rows in based on category using postgres policies?

I have a database of orders and each order has a time_slot (of type TIME). select id, time_slot from orders limit 5; 10 | 13:00:00 11 | 12:00:00 13 | 11:00:00 14 | 12:30:00 15 | 11:30:00 I want ...
Spaceface16518's user avatar
0 votes
0 answers
1k views

Supabase/Postgres: Row Level Security (RLS) on a join table

I have the following tables in a Supabase project: users --- id (uuid - ref auth.users.id) workspaces --- id (varchar) user_workspaces --- user_id workspace_id I want to set RLS on the join table, ...
Blumenthaler's user avatar
0 votes
0 answers
385 views

Supabase RLS not restricting reads

I am using Supabase and I have RLS enabled on my database table but I can still read data with the anonymous key. Why is this? const { createClient } = require('@supabase/supabase-js') const ...
Jordan Baron's user avatar