<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sabin Shrestha</title>
    <description>The latest articles on Forem by Sabin Shrestha (@sabin_shrestha_c134ef4405).</description>
    <link>https://forem.com/sabin_shrestha_c134ef4405</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3169531%2Fff684785-6dc5-4d6c-9bf2-6e8ac4d23740.png</url>
      <title>Forem: Sabin Shrestha</title>
      <link>https://forem.com/sabin_shrestha_c134ef4405</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sabin_shrestha_c134ef4405"/>
    <language>en</language>
    <item>
      <title>Production-Ready JWT + RBAC Auth for NestJS (With Structured API Responses)</title>
      <dc:creator>Sabin Shrestha</dc:creator>
      <pubDate>Mon, 17 Nov 2025 09:31:44 +0000</pubDate>
      <link>https://forem.com/sabin_shrestha_c134ef4405/production-ready-jwt-rbac-auth-for-nestjs-with-structured-api-responses-4508</link>
      <guid>https://forem.com/sabin_shrestha_c134ef4405/production-ready-jwt-rbac-auth-for-nestjs-with-structured-api-responses-4508</guid>
      <description>&lt;p&gt;Skip the long setup and get secure, multi-device authentication with refresh token rotation in just a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzi9bwjr7x320avkfxhi.png" alt=" " width="800" height="266"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Why This Boilerplate Exists
&lt;/h2&gt;

&lt;p&gt;Most NestJS developers eventually hit the same bottleneck:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I build secure authentication without spending days wiring everything together?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I ran into this repeatedly. Setting up JWT flows, refresh token rotation, HttpOnly cookies, RBAC, device sessions, rate limiting, logging, structured API responses, and proper error handling shouldn’t take a week — but it often does.&lt;/p&gt;

&lt;p&gt;This boilerplate packages all of this into a &lt;strong&gt;clean, production-ready setup&lt;/strong&gt; you can start using immediately.&lt;/p&gt;




&lt;h2&gt;
  
  
  Features Included
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JWT access + refresh tokens&lt;/li&gt;
&lt;li&gt;Refresh rotation&lt;/li&gt;
&lt;li&gt;HttpOnly cookies&lt;/li&gt;
&lt;li&gt;Declarative RBAC&lt;/li&gt;
&lt;li&gt;Multi-device sessions&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Global API response interceptor&lt;/li&gt;
&lt;li&gt;Centralized exception filters&lt;/li&gt;
&lt;li&gt;Prisma + PostgreSQL&lt;/li&gt;
&lt;li&gt;Pino structured logging with PII redaction&lt;/li&gt;
&lt;li&gt;Prebuilt Postman API collection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Full write-up on Medium:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://medium.com/@sabin.shrestha.er/stop-rebuilding-auth-a-production-ready-jwt-rbac-template-for-nestjs-18d99f9b8944" rel="noopener noreferrer"&gt;Stop Rebuilding Auth: A Production-Ready JWT + RBAC Template for NestJS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/masabinhok/nestjs-jwt-rbac-boilerplate" rel="noopener noreferrer"&gt;nestjs-jwt-rbac-boilerplate&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
# Clone the repo
git clone https://github.com/masabinhok/nestjs-jwt-rbac-boilerplate.git app-name
cd app-name

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env

# Run database migrations
npm run prisma:migrate

# Start development server
npm run start:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>security</category>
      <category>node</category>
      <category>backend</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
