Skip to content

Keys prc2?

All projects

SERVICE 03

PORT

Multi-Tenant RBAC Platform

  • 200+concurrent users
  • 120msquery latency
  • 0cross-tenant leaks

Stack React.js · Node.js · PostgreSQL · JWT · Azure App Service · Docker

Explain at

Role-based access control with JWT authentication, row-level PostgreSQL policies and per-tenant audit logging. Load-tested with more than 200 concurrent users: zero cross-tenant leakage across 10K+ policy evaluations per session. Query latency fell from 340 ms to 120 ms by removing N+1 patterns and adding tenant-scoped composite indexes; connection-pool reuse was tuned to keep latency stable in bursts.

In plain words Pick who is asking and what they want to do; the rulebook says allow or deny and writes down why. The big button tries ten thousand requests, half of them from the wrong company, and counts how many get through.

The playground runs in two web workers in your browser. This is the rulebook it applies.

Rule 0, checked first: a request from one tenant for another tenant’s rows is always refused.

Each action lists the lowest role that may do it; higher roles may too.

project
read: viewer · write: member · delete: admin · share: member
task
read: viewer · write: member · delete: member · share: member
audit log
read: admin · write: nobody · delete: nobody · share: nobody
billing
read: admin · write: owner · delete: nobody · share: nobody

A TypeScript port of the policy logic. In production the same rules were enforced by PostgreSQL row-level policies and JWT claims; the 200+ user figure is from the production load test, not from this fuzz.

Work trace

Decisions
Enforce isolation in the database with row-level policies, not only in application checks; audit per tenant from day one.
Trade-offs
Row-level policies add a predicate to every query; the tenant-scoped composite indexes are what kept that predicate cheap.
What broke
Queries were taking 340 ms. Removing the N+1 query patterns and adding tenant-scoped composite indexes took them to 120 ms.
What I'd change
Run the cross-tenant fuzz in CI on every change, the way this page runs it in your browser.
JWT
API(Node.js)
policy evaluator
row-level policies
audit log
tenant-scoped indexes
Click a part of the drawing to read about it.

Pipeline

  1. verify—
  2. evaluate—
  3. audit—

Run it to see the real timing of each stage.