Maps business roles to atomic capabilities with inheritance and domain wildcards, resolved in memory without extra database queries. Registered through a plugin that takes a roles map, with helpers to guard collection and field access and to check capabilities in server code. Combinators merge boolean checks with Payload Where constraints. Requires Payload 3.
Role-Based Access Control (RBAC) and capability engine for Payload CMS
Installation
npm i @payload-kit/rbac0
Stars
0
Forks
3
Open Issues
Yesterday
Last Updated
597
Weekly Downloads
v0.1.0-alpha.1
npm Version
110.3 KB
Unpacked Size
0
Dependencies
00 since Nov 22
| Date | Stars |
|---|---|
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
Shared by 5 plugins in gngz/payload-kit.
Trends appear after 7 days of data. Collecting since Dec 2 — 4 daily snapshots so far.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1474969753-rbac)<a href="https://payloaddirectory.dev/plugins/1474969753-rbac"><img src="https://payloaddirectory.dev/badge/1474969753-rbac.svg" alt="Payload Directory"></a>README
Role-Based Access Control (RBAC) and capability engine for Payload CMS. Maps business roles to atomic capabilities with inheritance, domain wildcards (orders:*, *), collection and field access guards, and logical combinators (and, or, not) where and/or preserve Payload Where query constraints.
pnpm add @payload-kit/rbac
Peer dependency: payload (^3.0.0).
import { buildConfig } from "payload";
import { rbacPlugin } from "@payload-kit/rbac";
export default buildConfig({
plugins: [
rbacPlugin({
roles: {
customer: {
label: "Customer",
capabilities: ["orders:create", "orders:read-own"],
},
operator: {
label: "Operator",
capabilities: ["orders:read", "orders:update", "inventory:manage"],
inherits: ["customer"],
},
admin: {
label: "Administrator",
capabilities: ["*"],
},
},
defaultRole: "customer",
superAdminRole: "admin",
}),
],
});
superAdminRole is opt-in (undefined by default); set it explicitly (e.g. "admin") to enable super-admin capability bypass. Capability resolution runs in memory with no extra database queries and handles circular inheritance safely.
Combinators (or, and) merge boolean capability checks with Payload Row-Level Security (Where) filters (not inverts boolean rules and throws a TypeError on Where clauses):
import type { CollectionConfig } from "payload";
import { and, nobody, or, requireAuth, requireCapability, requireRole } from "@payload-kit/rbac";
export const Orders: CollectionConfig = {
slug: "orders",
access: {
read: or(requireCapability("orders:read"), ({ req: { user } }) => ({
"customer.email": { equals: user?.email },
})),
create: and(requireAuth(), requireCapability("orders:create")),
update: requireCapability("orders:update"),
delete: requireCapability("orders:delete"),
},
fields: [],
};
export const AuditLogs: CollectionConfig = {
slug: "audit-logs",
access: {
create: nobody,
update: nobody,
delete: requireRole("admin"),
},
fields: [],
};
Use field guards to restrict sensitive fields or prevent privilege escalation on role fields:
import {
readOnlyField,
requireFieldCapability,
requireFieldRole,
systemOnlyField,
} from "@payload-kit/rbac";
export const Users = {
slug: "users",
fields: [
{
name: "role",
type: "select",
access: {
update: requireFieldCapability("users:manage"),
},
},
{
name: "internalNotes",
type: "textarea",
access: {
read: requireFieldRole(["admin", "operator"]),
update: requireFieldCapability("users:manage"),
},
},
{
name: "oidcSub",
type: "text",
access: readOnlyField(),
},
{
name: "webhookSecret",
type: "text",
access: systemOnlyField(),
},
],
};
import { hasAnyCapability, hasCapability, hasRole } from "@payload-kit/rbac";
if (hasCapability(user, "inventory:manage")) {
// allow stock update
}
if (hasAnyCapability(user, ["orders:update", "orders:delete"])) {
// show management actions
}
if (hasRole(user, "admin")) {
// admin-only branch
}
createRbacWhen you need an RBAC engine scoped to a specific tenant or module instead of the global registry:
import { createRbac } from "@payload-kit/rbac";
const appRbac = createRbac({
roles: {
viewer: { capabilities: ["reports:view"] },
editor: { capabilities: ["reports:*"], inherits: ["viewer"] },
},
});
const canExport = appRbac.hasCapability(user, "reports:export");
RbacPluginOptions)roles: Map of role names to { label?, capabilities, inherits? }.capabilities: Optional exhaustive list of valid capabilities.defaultRole: Default role applied by createRoleField / rbac.roleField().superAdminRole: Optional role that bypasses all capability checks (opt-in; e.g. "admin").anonymousRole: Optional role for unauthenticated visitors in role/capability checkers.userCollectionSlug: Optional user collection slug enforced during runtime user.collection validation (fails closed for other auth collections when set).rolesFieldName: Field name storing the user role(s) (default "role").createRoleField(options, overrides?) / rbac.roleField(overrides?): Field builder returning a write-protected SelectField that you can place anywhere in your users collection (fields, tabs, row, or sidebar).hasRole(user, role, options?): Checks whether the user has the given role.hasAnyRole(user, roles, options?): Checks whether the user has at least one listed role.hasAllRoles(user, roles, options?): Checks whether the user has every listed role.hasCapability(user, capability, options?): Evaluates wildcards, inheritance, and superAdminRole.hasAnyCapability(user, capabilities, options?): Checks whether the user has at least one capability.hasAllCapabilities(user, capabilities, options?): Checks whether the user has every listed capability.nobody / denyAll: Always returns false.anyone / allowAll: Always returns true.requireAuth(options?): Requires an authenticated user (accepts AuthCheckOptions with userCollectionSlug, failing closed for other auth collections when configured).requireRole(role | role[]): Requires one of the listed roles.requireCapability(capability | capability[], options?): Requires matching capability.or(...rules): Returns true if any rule returns true, merges Where clauses with { or: [...] }, or returns false if all deny.and(...rules): Returns false if any rule returns false, merges Where clauses with { and: [...] }, or returns true if all allow.not(rule): Inverts a boolean access decision.readOnlyField(): Returns { create: nobodyField, update: nobodyField }.systemOnlyField(): Returns { create: nobodyField, read: nobodyField, update: nobodyField }.nobodyField / denyField: Always returns false.anyoneField / allowField: Always returns true.requireFieldAuth(options?), requireFieldRole(role | role[]), requireFieldCapability(capability | capability[], options?): Field-level equivalents of the collection guards (requireFieldAuth accepts AuthCheckOptions for userCollectionSlug enforcement).fieldOr(...rules), fieldAnd(...rules), fieldNot(rule): Boolean combinators for field access.MIT
Tags
payload access plugin
Editable roles and an access matrix for per-collection, global and field permissions in the Payload admin
350v3
payload plugin positions
Scoped, dated position grants for users on a site, organization or project, with host-defined types and an audit trail
76382/wk0v3
payload plugin roles
Per-site role ladders and access helpers for multi-tenant Payload sites
76128/wk0v3
payload plugin guard
Central access policy file, typed predicates and guarded endpoints for Payload plugins and Local API calls
73664/wk37v3
rbac
Database-stored roles with a per-collection CRUD permission matrix enforced across all collections and globals
61205/wk16v3
rbac
Database-driven role-based access control with a per-collection permissions matrix and admin localization
5915/wk0v4