<?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>DEV Community: KASOIR ABBAS</title>
    <description>The latest articles on DEV Community by KASOIR ABBAS (@kasoir_abbas_7d626c407602).</description>
    <link>https://dev.to/kasoir_abbas_7d626c407602</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4060250%2F09c86743-26f0-4499-9206-26c13a9ee1d3.png</url>
      <title>DEV Community: KASOIR ABBAS</title>
      <link>https://dev.to/kasoir_abbas_7d626c407602</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kasoir_abbas_7d626c407602"/>
    <language>en</language>
    <item>
      <title>Building Multi-Tenant Auth from Scratch Is Painful. So I Open-Sourced MT-URBAC (NestJS + Angular)</title>
      <dc:creator>KASOIR ABBAS</dc:creator>
      <pubDate>Tue, 11 Aug 2026 04:14:30 +0000</pubDate>
      <link>https://dev.to/kasoir_abbas_7d626c407602/building-multi-tenant-auth-from-scratch-is-painful-so-i-open-sourced-mt-urbac-nestjs-angular-iod</link>
      <guid>https://dev.to/kasoir_abbas_7d626c407602/building-multi-tenant-auth-from-scratch-is-painful-so-i-open-sourced-mt-urbac-nestjs-angular-iod</guid>
      <description>&lt;p&gt;Every time you build a SaaS product, you hit the same wall: spending the first few days re-writing multi-tenant architecture, handling tenant context isolation, setting up JWT guards, and building permission directives.&lt;/p&gt;

&lt;p&gt;After open-sourcing the initial Unified Role-Based Access Control boilerplate, the most common question I thought about was: “How to scale this for multi-tenancy?”&lt;/p&gt;

&lt;p&gt;Building multi-tenant apps means dealing with a cascade of complexities: tenant context resolution, isolated access control policies, routing adjustments, and clean database partitioning. Building all of that from scratch for every B2B SaaS project is a massive time sink.&lt;/p&gt;

&lt;p&gt;So I built a production-ready solution once, engineered it cleanly, and open-sourced it: MT-URBAC (Multi-Tenant Unified Role-Based Access Control).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is MT-URBAC?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;MT-URBAC is a full-stack, enterprise-grade boilerplate designed to let you spin up a secure, multi-tenant B2B application in under five minutes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend: NestJS, TypeORM, PostgreSQL&lt;/li&gt;
&lt;li&gt;Frontend: Angular, OptimusUI, Tailwind CSS&lt;/li&gt;
&lt;li&gt;License: 100% Free &amp;amp; Open-Source (MIT)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Architectural Breakthroughs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Zero-Hassle Local Multi-Tenant Routing&lt;/strong&gt;&lt;br&gt;
Testing subdomains locally usually requires hacking your OS /etc/hosts file and running custom proxy configurations. MT-URBAC solves this out of the box with dual-mode routing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local Development (Path-Based): Zero setup required. Test tenant boundaries instantly using clean paths like &lt;a href="http://localhost:4200/tenant-a/login" rel="noopener noreferrer"&gt;http://localhost:4200/tenant-a/login&lt;/a&gt; or &lt;a href="http://localhost:4200/admin/" rel="noopener noreferrer"&gt;http://localhost:4200/admin/&lt;/a&gt;....&lt;/li&gt;
&lt;li&gt;Production (Subdomain-Based): Automatically maps incoming host headers (tenant-a.yourdomain.com) to tenant contexts seamless in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Clean Top-Down Grouping (No Junction-Table Hell)&lt;/strong&gt;&lt;br&gt;
Instead of messy three-way many-to-many junction tables that destroy query performance, MT-URBAC enforces a streamlined hierarchy:&lt;br&gt;
&lt;code&gt;User → Group → Role → Privilege&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Automatic Privilege Escalation Defense&lt;/strong&gt;&lt;br&gt;
Security flaw #1 in custom RBAC systems is horizontal/vertical privilege escalation (e.g., an Admin granting someone Super Admin privileges). MT-URBAC assigns numeric weight levels to every role (e.g., Admin = 50, Super Admin = 100). The NestJS guards intercept and reject any action where a user attempts to mutate or assign a role higher than their own level.&lt;/p&gt;
&lt;h2&gt;
  
  
  Developer Experience (DX) First
&lt;/h2&gt;

&lt;p&gt;Protecting backend endpoints takes a single line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;create&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;RequirePermissions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user:create&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;createNewUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Executed only if the user possesses 'user:create' in their active tenant context&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hiding or rendering elements dynamically in Angular requires zero boilerplate logic in your components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Automatically listens to user permission state --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;*hasPermission=&lt;/span&gt;&lt;span class="s"&gt;"'user:delete'"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"p-button-danger"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Delete User
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Try It in 2 Minutes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Clone &amp;amp; install&lt;/span&gt;
git clone https://github.com/kasoir/mt-urbac.git
&lt;span class="nb"&gt;cd &lt;/span&gt;mt-urbac/backend &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# 2. Seed database &amp;amp; start&lt;/span&gt;
npm run seed
npm run start:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repository ships with an automated database seeder that provisions default roles, privileges, and a Super Admin account out of the box (&lt;a href="mailto:admin@mt-urbac.com"&gt;admin@mt-urbac.com&lt;/a&gt; / Admin123!).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check out the source code on GitHub&lt;/strong&gt;: &lt;a href="https://github.com/kasoir/mt-urbac" rel="noopener noreferrer"&gt;https://github.com/kasoir/mt-urbac&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this saves you a weekend of architecture setup, drop a Star on the repo! I'd love to hear in the comments how you typically handle multi-tenancy isolation in your projects.&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>angular</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>To avoid rebuilding Auth every time, I open-sourced URBAC (Unified RBAC) (NestJS + Angular + PostgreSQL)</title>
      <dc:creator>KASOIR ABBAS</dc:creator>
      <pubDate>Mon, 03 Aug 2026 09:51:23 +0000</pubDate>
      <link>https://dev.to/kasoir_abbas_7d626c407602/i-got-tired-of-rebuilding-auth-so-i-open-sourced-urbac-nestjs-angular-postgresql-gf4</link>
      <guid>https://dev.to/kasoir_abbas_7d626c407602/i-got-tired-of-rebuilding-auth-so-i-open-sourced-urbac-nestjs-angular-postgresql-gf4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: I've migrated the boilerplate from PrimeNG to OptimusUI to keep the project completely open-source and free under the MIT license! The Tailwind CSS integration remains just as smooth.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every time I start a new full-stack project, the first week is always the same: setting up users, configuring database relationships, writing JWT guards, and building route protectors.&lt;/p&gt;

&lt;p&gt;Role-Based Access Control (RBAC) is something every enterprise app needs, but building a clean, scalable version of it from scratch every single time is exhausting.&lt;/p&gt;

&lt;p&gt;So, I decided to build it once, build it right, and open-source it for everyone.&lt;/p&gt;

&lt;p&gt;Meet URBAC (Unified Role-Based Access Control).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is URBAC?&lt;/strong&gt;&lt;br&gt;
URBAC is a production-ready, full-stack boilerplate designed to help you scaffold secure, multi-level access control systems in minutes.&lt;/p&gt;

&lt;p&gt;The stack is strictly built for enterprise scale:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend: NestJS &amp;amp; TypeORM&lt;/li&gt;
&lt;li&gt;Frontend: Angular (with PrimeNG &amp;amp; Tailwind CSS)&lt;/li&gt;
&lt;li&gt;Database: PostgreSQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Architecture&lt;/strong&gt;&lt;br&gt;
Instead of using messy, complicated three-way junction tables, I architected URBAC with a clean, top-down administrative grouping model. This makes the database queries lightning-fast and the mental model incredibly easy to understand:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Groups are administrative buckets (e.g., "Users", "Admins", "Super Admins").&lt;/li&gt;
&lt;li&gt;Users are assigned to a Group.&lt;/li&gt;
&lt;li&gt;Roles are assigned to a Group.&lt;/li&gt;
&lt;li&gt;Privileges are attached to Roles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It also features Role Escalation Security. Every role has a numeric level (e.g., Admin = 50, Super Admin = 100). The backend guards automatically ensure that a Level 10 user can never grant someone a Level 50 role.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer Experience First&lt;/strong&gt;&lt;br&gt;
I wanted this template to feel like magic when you use it.&lt;/p&gt;

&lt;p&gt;On the backend, protecting a route is as simple as dropping a custom decorator on your NestJS controller:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Post('create')&lt;br&gt;
@RequirePermissions('user:create')&lt;br&gt;
async createNewUser() { &lt;br&gt;
  // Only users with this specific privilege can execute this&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
On the frontend, I built a custom structural directive for Angular that reacts to the logged-in user's active group context. Hiding buttons from unauthorized users takes one line of HTML:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;button *hasPermission="'user:delete'" class="p-button-danger"&amp;gt;&lt;br&gt;
  Delete User&lt;br&gt;
&amp;lt;/button&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it out&lt;/strong&gt;&lt;br&gt;
The repository comes with a database seed script that instantly provisions a Super Admin account (&lt;a href="mailto:admin@urbac.com"&gt;admin@urbac.com&lt;/a&gt;), so you can clone it, run npm run seed, and immediately log into the dashboard to start managing roles.&lt;/p&gt;

&lt;p&gt;You can check out the full source code and documentation here: &lt;a href="https://github.com/kasoir/urbac" rel="noopener noreferrer"&gt;URBAC&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you find this template useful for your next NestJS/Angular project, I would hugely appreciate a star on GitHub! Let me know in the comments what features or auth modules you'd like to see added next.&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>angular</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
