PostgreSQL Row Level Security
Early on, I had to figure out how to keep users' recipes private. The obvious approach: check permissions in the app code before every query. But what happens when I inevitably mess up and forget a check somewhere?
PostgreSQL's Row Level Security became my safety net. It enforces access control at the database level, users literally can't query recipes that aren't theirs, even if my app code screws up.
Supabase handles the authentication context through JWTs, and RLS policies automatically scope every query to the logged-in user. The app doesn't even know it's happening.
It's defense in depth. Even if there's a bug in my code, the database won't leak data. Turned out to be a good lesson in designing for serverless environments where you can't rely on traditional middleware to catch mistakes.