Postgres Row-Level Security is notoriously difficult to comprehend and use. The policy access model for a todos table in a Todo List app can be declared as per the following table:
This is an extremely low-level API. And for most applications and data models, it will get very repetitive. So, we’ve designed a more concise API that’s specifically designed for CRUD apps.
The authUid function is specific to pg_session_jwt, but its implementation is very simple. It simply allows you to connect auth.user_id to a column in your table.
This API is a much higher-level abstraction on top of Postgres RLS, which will hopefully be helpful to anyone using Postgres RLS (on Neon, or not, with pg_session_jwt or not).
Coming soon: If you’re curious about this API and what it looks like in a more complete data model, we’ll be publising a blog post with a reference RLS implemenration for a social media network.