SupabaseS
Supabase12mo ago
Geo⭐

Storage RLS not working when querying a table in public

Hello,

I've setup successfully RLS on my tables, but when I try to configure it on my buckets, it doesnt work.

I have a table named roles where i store users' auth id (column user_id), and the team_id.

If I bullt the RLS policy hardcoding the team_id it works, like this example

((bucket_id = 'media') AND ('00001' = (storage.foldername(name))[1]))

but when i try to retrieve the team_id from the roles table, it fails:

bucket_id = 'media' AND
EXISTS (
SELECT 1
FROM roles
WHERE user_id = auth.uid()
AND team_id = (storage.foldername(name))[1]
)

FYI: my supabase instance its self-hosted in docker

Thanks you in advance and happy holidays 😄
Was this page helpful?