Browse docs
Browse docs
Production-grade role-based access control for securing UI components, routes, and actions in Dashforge applications.
Dashforge Access Control is a role-based permission system that determines who can do what in your application. Instead of scattering permission checks throughout your code, you define a central policy that maps roles to permissions, then the system enforces those rules automatically.
The system integrates directly with Dashforge components. Fields can hide, disable, or become read-only based on permissions. Navigation items filter automatically. Routes protect themselves. No manual wiring required.
import { TextField } from '@dashforge/tw';
function BookingForm() {
return (
<TextField
name="customerName"
label="Customer Name"
access={{
action: 'edit',
resource: 'booking',
onUnauthorized: 'readonly'
}}
/>
);
}
// Field becomes read-only if user lacks 'edit booking' permission
// No manual if statements. No scattered checks. Just declarative access.Without a central access control system, permission logic spreads across your entire application. Every component needs to know who the current user is, what roles they have, and what they're allowed to do. This creates three major problems:
// BEFORE: Manual permission checks scattered everywhere
function BookingForm({ user }) {
const canEdit = user.roles.includes('admin') ||
user.roles.includes('editor');
const canDelete = user.roles.includes('admin');
return (
<>
<TextField
name="customerName"
disabled={!canEdit}
/>
<TextField
name="bookingDate"
disabled={!canEdit}
/>
{canDelete && <Button>Delete</Button>}
</>
);
}
// Every component duplicates this logic
// Changing "who can edit" requires finding all these checks
// Easy to miss one. Easy to create inconsistencies.Dashforge RBAC solves this by centralizing all permission logic in a single policy. Components declare what they need. The system enforces it automatically.
Dashforge Access Control is built on three core capabilities:
hide, disable, or become readonly when access is denied. Declarative. No manual if statements.useCan, useRbac), declarative components (Can), and all Dashforge form fields (TextField, Select, etc.).Dashforge RBAC is structured in three distinct layers, each with a clear responsibility:
Framework-agnostic RBAC engine. Evaluates permissions, resolves roles, handles precedence. Pure functions. Zero dependencies.
React-specific bindings. Provides RbacProvider, useRbac, useCan hooks, and Can component. Manages context and lifecycle.
Dashforge-specific utilities. Includes resolveAccessState (for components), filterNavigationItems (for LeftNav), filterActions (for toolbars), and createAccessGuard (for routes).
This separation means you can use the core engine anywhere (even outside React), use the React layer in any React app, and use the Dashforge layer only when working with Dashforge components.
Use Dashforge RBAC when you need:
Don't use RBAC if: