Hello PostgreSQL Community, I am developing a multi-tenant SaaS application using PostgreSQL 17, Supabase, PostgREST, and Next.js.
I would appreciate technical guidance on designing a secure database authorization model. Specifically: 1. What is the recommended lock-ordering strategy when authorization depends on session, membership, role, and tenant records? 2. Is READ COMMITTED with explicit row locks and post-lock authority revalidation an appropriate approach? 3. What is the recommended least-privilege ownership and permission model for SECURITY DEFINER functions that require row-level locking? 4. How should concurrent authorization changes, deadlocks, and transaction retries be handled without weakening security? 5. Are there recommended reference implementations or concurrency-testing practices for this architecture? My goal is to follow PostgreSQL-supported security practices without granting excessive privileges or modifying managed authentication internals. Any technical guidance or relevant documentation would be greatly appreciated. Thank you.
