Supabase: Understanding auth.uid() function and RLS
내 ID가 왜 달라요? (auth.uid() vs user_id)
Confused by auth.uid()? Learn how to correctly fetch the current user ID in Postgres functions, RLS policies, and Triggers. Deep dive into Security Definer.
c
codemapo
INTERDISCIPLINARY DEV · SEOUL
8. Summary
auth.uid() needs Context. It dies outside API calls.
Always Null-check in Triggers to support batch/admin operations.
Use security definer to bypass permission blocks safely, but handle with care ("sudo" mode).
Leverage auth.jwt() for high-performance role checks without joins.
Supabase Auth is powerful, but it's not magic. It's pure, strict SQL living inside a stateless API world. Bridge the gap by programming defensively.