Skip to main content
Version: 4.x (latest)

RBAC shield and padlock

Authorization without surprises

@rbac/core is a TypeScript library for role-based access control in Node.js. Give roles permission to perform operations, optionally inherit permissions from other roles, then ask the library whether an operation is allowed.

It handles authorization, not authentication: your application identifies the user, determines the user's trusted role, and supplies any required context. RBAC returns a decision; your application enforces it.

A complete decision​

ts
import { createRBAC } from '@rbac/core';

const rbac = createRBAC({ roles: {
  viewer: { can: ['documents:read'] },
  editor: { inherits: ['viewer'], can: ['documents:edit'] }
} });

console.log(await rbac.can('editor', 'documents:read')); // true
console.log(await rbac.can('viewer', 'documents:edit')); // false
console.log(await rbac.can('unknown', 'documents:read')); // false

createRBAC({ roles, ...options }) returns an instance with can(), addRole(), and updateRoles(). Permission checks always return a promise, even for unconditional grants. Undefined roles and missing grants are denied by default.

What the library provides​

CapabilityRelevant guide
Exact permissions, inheritance, repeated conditional grantsRoles and permissions
Wildcards and regular expressionsPatterns
Request-aware rules and asynchronous predicatesConditions
Runtime role managementRuntime changes
Tenant-based persistenceDatabase adapters
Express, NestJS, FastifyMiddleware

Continue with installation, or try the interactive playground.

Brand assets​

The full RBAC logo and shield-and-padlock icon are transparent, fully vector SVGs with no external font dependencies. The visual identity uses blue #2563EB and navy #0F172A; the website also includes a light-wordmark variant for dark navigation backgrounds.