<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk" -->

---
title: Modelling Authorization for a Social Network with...
description: A deep dive into implementing Row-Level Security (RLS) in PostgreSQL for a Twitter-inspired social network, using Drizzle ORM and Neon's pg_session_jwt...
canonical: https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM | daily.dev
og:description: A deep dive into implementing Row-Level Security (RLS) in PostgreSQL for a Twitter-inspired social network, using Drizzle ORM and Neon's pg_session_jwt...
og:url: https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk
og:image: https://api.daily.dev/og/posts/Nj2KCV2Nk.png
og:image:alt: Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM

**[Neon](https://daily.dev/sources/neontech)** · 7 min read · 0 upvotes · 0 comments

## Summary

A deep dive into implementing Row-Level Security (RLS) in PostgreSQL for a Twitter-inspired social network, using Drizzle ORM and Neon's pg_session_jwt extension. Covers RLS policies for users/profiles, public posts/comments, and complex private chat scenarios including a workaround for circular RLS recursion using non-simple views. Key takeaways include advocating for Drizzle's crudPolicy over raw SQL policies, the importance of thorough RLS validation when exposing schemas directly to frontends, and the difficulty of testing RLS policies in practice.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://neon.com/blog/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm>

## Similar posts on daily.dev

- [Build a Multi-Tenant Saas API with NestJS and Postgres](https://daily.dev/posts/build-a-multi-tenant-saas-api-with-nestjs-and-postgres-weolds5ch) · Telerik · 0 upvotes · 0 comments
- [PostgreSQL Row-Level Security With EF Core and Npgsql](https://daily.dev/posts/postgresql-row-level-security-with-ef-core-and-npgsql-hwrvo7jim) · Milan Jovanović · 1 upvotes · 1 comments
- [Spark-Beyond Basics: Row Level Security in Databricks](https://daily.dev/posts/spark-beyond-basics-row-level-security-in-databricks-cccelqndw) · Towards Dev · 0 upvotes · 0 comments
- [Beyond tenant\_id: Treating Multi-Tenancy as a Database Invariant](https://daily.dev/posts/beyond-tenant-id-treating-multi-tenancy-as-a-database-invariant-dpssptbwc) · RUBYLAND · 10 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#authorization](https://daily.dev/tags/authorization)

[View this post on daily.dev](https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM","url":"https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk"},"datePublished":"2026-07-09T06:58:08.013Z","dateModified":"2026-07-09T07:01:47.905Z","description":"A deep dive into implementing Row-Level Security (RLS) in PostgreSQL for a Twitter-inspired social network, using Drizzle ORM and Neon's pg_session_jwt...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cc2b119bb4d47c2abd1c41d236423334?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/cc2b119bb4d47c2abd1c41d236423334?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Neon","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Neon","logo":"https://media.daily.dev/image/upload/s--65EDghou--/f_auto/v1724339118/logos/neontech","url":"https://daily.dev/sources/neontech"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-nj2kcv2nk","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,authorization","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Neon","item":"https://daily.dev/sources/neontech"},{"@type":"ListItem","position":3,"name":"Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM"}]}
```

