abc222
05/10/2022, 2:10 PMDanMossa
05/10/2022, 2:40 PMScott P
05/10/2022, 3:05 PMSECURITY INVOKER
, you'll be able to create a view from that which has RLS enforced.
Example: https://www.benburwell.com/posts/row-level-security-postgresql-views/
So it's already possible, but it's just not as straight-forward as having RLS controls directly on the view itself.
Also, I wouldn't consider security definers 'boilerplatey'. They're a core part of Postgres, and there's literally 2 choices - runs as creator (security definer
) or runs as executor (security invoker
)DanMossa
05/10/2022, 3:20 PMScott P
05/10/2022, 3:23 PMDanMossa
05/10/2022, 8:44 PMScott P
05/10/2022, 8:51 PMScott P
05/10/2022, 8:55 PMWHERE user_id = auth.uid() OR CURRENT_USER = 'postgres'::name;
in your view definition. This allows you to view all details if you're accessing the view as the postgres user, or only return certain rows for individual usersDanMossa
05/10/2022, 10:16 PMDanMossa
05/10/2022, 10:16 PM