NeonN
Neon6mo ago
5 replies
radical-lime

How to have both RLS via JWT and interactive transactions?

I'm working on a codebase where the db connection is using @neon/serverless and Pool, which makes interactive transactions with rollbacks possible. Recently we've started looking into having RLS as well. Following the guide for Neon Authorize, it seems we need to use @neon/http as a driver and pass the JWT token as an authToken while initializing the database. But then we'll get No transactions support in neon-http driver.

So I am just a little confused on whether we can have both RLS and interactive transactions. One thing I've tried is just passing the JWT token as a local session variable inside each transactions, which allowed the RLS policies to work while keeping our existing interactive transaction. But I am wondering if there's a better way to do it than that

TIA
Was this page helpful?