A step-by-step guide to implementing row-level security (RLS) in Postgres using AWS Cognito JWTs for authorization. The setup uses Neon as the serverless Postgres provider and Neon Authorize to validate JWTs and map their claims (specifically the `sub` claim) to Postgres session variables, enforcing per-user data access policies. The demo app uses Express.js and HTMX, with steps covering Cognito User Pool configuration, Postgres RLS policy setup, middleware integration, and local testing.
Table of contents
Teck Stack OverviewStep-by-step guide: AWS Cognito and Postgres’ Row-Level SecurityWrap up4 Impressions