Adds role-based access control to Payload v3 using permissions stored in the database as feature and action pairs, assigned to roles. It registers five RBAC collections, augments the users collection, and provides access helpers such as getPermissionAccess to enforce rules on app collections. Requires Payload 3.84.1 or later and a database migration after setup.
A plugin for Payload CMS to manage authentication and authorization
Installation
npm i @zealamic/payload-plugin-rbac10
Stars
1
Forks
0
Open Issues
5 months ago
Last Updated
74
Weekly Downloads
v1.3.0
npm Version
478.3 KB
Unpacked Size
0
Dependencies
10+3 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 10 |
| Dec 5, 2026 | 10 |
| Dec 4, 2026 | 10 |
| Dec 3, 2026 | 10 |
| Dec 2, 2026 | 10 |
| Dec 1, 2026 | 10 |
| Nov 30, 2026 | 10 |
| Nov 29, 2026 | 10 |
| Nov 28, 2026 | 10 |
| Nov 27, 2026 | 10 |
| Nov 26, 2026 | 10 |
| Nov 25, 2026 | 10 |
| Nov 24, 2026 | 10 |
| Nov 23, 2026 | 10 |
| Nov 22, 2026 | 10 |
| Nov 21, 2026 | 10 |
| Nov 20, 2026 | 10 |
| Nov 19, 2026 | 10 |
| Nov 18, 2026 | 10 |
| Nov 17, 2026 | 10 |
| Nov 16, 2026 | 10 |
| Nov 15, 2026 | 10 |
| Nov 14, 2026 | 10 |
| Nov 13, 2026 | 10 |
| Nov 12, 2026 | 10 |
| Nov 11, 2026 | 10 |
| Nov 10, 2026 | 10 |
| Nov 9, 2026 | 10 |
| Nov 8, 2026 | 10 |
| Nov 7, 2026 | 10 |
| Nov 6, 2026 | 10 |
| Nov 5, 2026 | 10 |
| Nov 4, 2026 | 10 |
| Nov 3, 2026 | 10 |
| Nov 2, 2026 | 10 |
| Nov 1, 2026 | 10 |
| Oct 31, 2026 | 10 |
| Oct 30, 2026 | 10 |
| Oct 29, 2026 | 10 |
| Oct 28, 2026 | 10 |
| Oct 27, 2026 | 10 |
| Oct 26, 2026 | 10 |
| Oct 25, 2026 | 10 |
| Oct 24, 2026 | 10 |
| Oct 23, 2026 | 10 |
| Oct 22, 2026 | 10 |
| Oct 21, 2026 | 10 |
| Oct 20, 2026 | 10 |
| Oct 19, 2026 | 10 |
| Oct 18, 2026 | 10 |
| Oct 17, 2026 | 10 |
| Oct 16, 2026 | 10 |
| Oct 15, 2026 | 10 |
| Oct 14, 2026 | 10 |
| Oct 13, 2026 | 10 |
| Oct 12, 2026 | 10 |
| Oct 11, 2026 | 10 |
| Oct 10, 2026 | 10 |
| Oct 9, 2026 | 10 |
| Oct 8, 2026 | 10 |
| Oct 7, 2026 | 10 |
| Oct 6, 2026 | 10 |
| Oct 5, 2026 | 10 |
| Oct 4, 2026 | 9 |
| Oct 3, 2026 | 9 |
| Oct 2, 2026 | 9 |
| Oct 1, 2026 | 9 |
| Sep 30, 2026 | 9 |
| Sep 29, 2026 | 9 |
| Sep 28, 2026 | 9 |
| Sep 27, 2026 | 9 |
| Sep 26, 2026 | 9 |
| Sep 25, 2026 | 9 |
| Sep 24, 2026 | 9 |
| Sep 23, 2026 | 9 |
| Sep 22, 2026 | 9 |
| Sep 21, 2026 | 9 |
| Sep 20, 2026 | 9 |
| Sep 19, 2026 | 9 |
| Sep 18, 2026 | 9 |
| Sep 17, 2026 | 9 |
| Sep 16, 2026 | 9 |
| Sep 15, 2026 | 9 |
| Sep 14, 2026 | 9 |
| Sep 13, 2026 | 8 |
| Sep 12, 2026 | 8 |
| Sep 11, 2026 | 8 |
| Sep 10, 2026 | 8 |
| Sep 9, 2026 | 7 |
| Sep 8, 2026 | 7 |
| Sep 7, 2026 | 7 |
72+49 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 72 |
| Dec 5, 2026 | 56 |
| Dec 4, 2026 | 45 |
| Dec 3, 2026 | 40 |
| Dec 2, 2026 | 58 |
| Dec 1, 2026 | 65 |
| Nov 30, 2026 | 61 |
| Nov 29, 2026 | 69 |
| Nov 28, 2026 | 66 |
| Nov 27, 2026 | 82 |
| Nov 26, 2026 | 86 |
| Nov 25, 2026 | 73 |
| Nov 24, 2026 | 75 |
| Nov 23, 2026 | 75 |
| Nov 22, 2026 | 63 |
| Nov 21, 2026 | 60 |
| Nov 20, 2026 | 38 |
| Nov 19, 2026 | 37 |
| Nov 18, 2026 | 29 |
| Nov 17, 2026 | 21 |
| Nov 16, 2026 | 17 |
| Nov 15, 2026 | 16 |
| Nov 14, 2026 | 19 |
| Nov 13, 2026 | 25 |
| Nov 12, 2026 | 24 |
| Nov 11, 2026 | 43 |
| Nov 10, 2026 | 53 |
| Nov 9, 2026 | 53 |
| Nov 8, 2026 | 59 |
| Nov 7, 2026 | 58 |
| Nov 6, 2026 | 58 |
| Nov 5, 2026 | 58 |
| Nov 4, 2026 | 42 |
| Nov 3, 2026 | 36 |
| Nov 2, 2026 | 35 |
| Nov 1, 2026 | 32 |
| Oct 31, 2026 | 40 |
| Oct 30, 2026 | 40 |
| Oct 29, 2026 | 34 |
| Oct 28, 2026 | 31 |
| Oct 27, 2026 | 27 |
| Oct 26, 2026 | 28 |
| Oct 25, 2026 | 27 |
| Oct 24, 2026 | 26 |
| Oct 23, 2026 | 19 |
| Oct 22, 2026 | 33 |
| Oct 21, 2026 | 50 |
| Oct 20, 2026 | 67 |
| Oct 19, 2026 | 81 |
| Oct 18, 2026 | 95 |
| Oct 17, 2026 | 100 |
| Oct 16, 2026 | 108 |
| Oct 15, 2026 | 147 |
| Oct 14, 2026 | 138 |
| Oct 13, 2026 | 123 |
| Oct 12, 2026 | 119 |
| Oct 11, 2026 | 107 |
| Oct 10, 2026 | 94 |
| Oct 9, 2026 | 166 |
| Oct 8, 2026 | 455 |
| Oct 7, 2026 | 450 |
| Oct 6, 2026 | 447 |
| Oct 5, 2026 | 439 |
| Oct 4, 2026 | 438 |
| Oct 3, 2026 | 446 |
| Oct 2, 2026 | 366 |
| Oct 1, 2026 | 39 |
| Sep 30, 2026 | 43 |
| Sep 29, 2026 | 48 |
| Sep 28, 2026 | 45 |
| Sep 27, 2026 | 47 |
| Sep 26, 2026 | 41 |
| Sep 25, 2026 | 55 |
| Sep 24, 2026 | 43 |
| Sep 23, 2026 | 42 |
| Sep 22, 2026 | 43 |
| Sep 21, 2026 | 67 |
| Sep 20, 2026 | 78 |
| Sep 19, 2026 | 76 |
| Sep 18, 2026 | 70 |
| Sep 17, 2026 | 73 |
| Sep 16, 2026 | 70 |
| Sep 15, 2026 | 67 |
| Sep 14, 2026 | 43 |
| Sep 13, 2026 | 28 |
| Sep 12, 2026 | 38 |
| Sep 11, 2026 | 35 |
| Sep 10, 2026 | 30 |
| Sep 9, 2026 | 29 |
| Sep 8, 2026 | 21 |
| Sep 7, 2026 | 23 |
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/1251146173-root)<a href="https://payloaddirectory.dev/plugins/1251146173-root"><img src="https://payloaddirectory.dev/badge/1251146173-root.svg" alt="Payload Directory"></a>README
Centralized role-based access control (RBAC) for Payload CMS v3 (payload ^3.84.1). Not compatible with Payload 2.x.

Permissions live in the database (feature + action), are assigned to roles, and enforced via reusable access helpers — editable in Admin without redeploying policy code.
Row-level access (
dataScope): list collection slugs intargetCollectionsfor auto ownership field + create hook, then wiregetPermissionAccess. → COLLECTIONS — targetCollections · manual setup → UTILS
| Guide | Read when you need to… |
|---|---|
| COLLECTIONS | Plugin collections, users augmentation, dataScope, permission matrix, field/access overrides |
| UTILS | getPermissionAccess, data-scope filters, field merge helpers |
| TRANSLATIONS | Admin labels, select options, matrix UI strings (en, vi, …) |
| CUSTOM_COMPONENTS | Custom matrix checkboxes / search input (client field component) |
Typical flow: install → register plugin with targetCollections (COLLECTIONS) → run migration → seed RBAC data (COLLECTIONS) → add getPermissionAccess on app collections (UTILS) → translate Admin UI (TRANSLATIONS).
Demos in this repo: dev/rbac.ts, dev/collections/posts.ts, dev/components/role-permission-matrix-field.tsx.
featureCode + actionCode pair (helpers)own / hierarchy / all; use targetCollections for ownership field + hook, or add manually (UTILS)targetCollections — auto-add hidden ownership field + create hook on app collections (COLLECTIONS)config.admin.user (default users) for hierarchy + options.usersCollectionSlugroles-permissions on savesortOrder for permission features and actions on each collection list viewnpm install @zealamic/payload-plugin-rbac
# or: yarn add / pnpm add @zealamic/payload-plugin-rbac
import { payloadPluginRBAC } from "@zealamic/payload-plugin-rbac";
export default buildConfig({
plugins: [
payloadPluginRBAC({
autoModifyUsersCollection: true, // roles, isSuperAdmin, parent, default user access
targetCollections: ["posts"], // ownership field + create hook — see step 4
// collections: { ... } → https://github.com/zealamic/payload-plugin-rbac/blob/main/docs/COLLECTIONS.md
// translations: { ... } → https://github.com/zealamic/payload-plugin-rbac/blob/main/docs/TRANSLATIONS.md
// components: { rolePermissionMatrixField: "..." } → custom matrix Field (client module)
}),
],
});
After adding the plugin (and especially after changing targetCollections), update your database schema:
yarn payload migrate:create
yarn payload migrate
(npm run / pnpm equivalents work too.)
Run migrate:create when new fields are added to collections (e.g. first time you list a slug in targetCollections). Then migrate to apply pending migrations.
Bootstrap a super admin: RBAC collections are restricted to super admins by default. Set
isSuperAdmin: trueon at least one user (via seed script, Local API, or direct database update) before you can manage roles, permissions, and the permission matrix in Admin.
posts, users (code = featureCode in access helpers); use Reorder on the list view to set row order in the matrixcreate, read, update, delete (main / sub types); use Reorder to set main column and sub-action orderstatus: active)→ Full reference: COLLECTIONS
Recommended: list slugs in targetCollections — the plugin adds a hidden ownership field (createdBy text by default) and a create hook. You only wire getPermissionAccess on the collection. Full options → COLLECTIONS — targetCollections.
// payload.config.ts
payloadPluginRBAC({
targetCollections: ["posts"],
});
// collections/posts.ts — no manual createdBy field or hook needed
import type { CollectionConfig } from "payload";
import { getPermissionAccess } from "@zealamic/payload-plugin-rbac";
export const Posts: CollectionConfig = {
slug: "posts",
access: {
read: getPermissionAccess({ featureCode: "posts", actionCode: "read", options: {} }),
create: getPermissionAccess({ featureCode: "posts", actionCode: "create" }),
update: getPermissionAccess({ featureCode: "posts", actionCode: "update", mode: "modify" }),
delete: getPermissionAccess({ featureCode: "posts", actionCode: "delete", mode: "modify" }),
},
fields: [{ name: "title", type: "text", required: true }],
};
After adding or changing targetCollections, run yarn payload migrate:create then yarn payload migrate.
Manual setup (visible fields, custom layout, or full control): add ownership field + create hook yourself → UTILS — Ownership field · relationship demo: dev/collections/posts.ts
Access order: no user → deny · super admin → allow · else → matrix permission (+ scope when options / mode: "modify").
List views for permission-features and permission-actions include a Reorder drawer to set sortOrder (hidden on edit forms). Order drives the role permission matrix: features → rows, main actions → columns, sub actions → checkbox order under each row.

| Step | Action |
|---|---|
| Features | Permission Features → Reorder → drag → Save order |
| Actions | Permission Actions → Reorder → pick Main or Sub → drag → Save order |

API: POST /api/permission-features/reorder · POST /api/permission-actions/reorder — body { "sortedItems": [{ "id": "…", "sortOrder": 0 }] }. Requires update access (super admin by default). Details → COLLECTIONS · labels → TRANSLATIONS — Reorder drawers.
| Option | Default | Description |
|---|---|---|
disabled | false | Skip runtime i18n/onInit wiring; collections still register in schema |
autoModifyUsersCollection | true | Add RBAC fields, parent-path hooks, and default access on the auth users collection |
targetCollections | — | Auto ownership field + create hook on listed app collections → COLLECTIONS |
translations | — | Admin + matrix i18n → TRANSLATIONS |
collections | — | Per-collection fields / access / admin overrides → COLLECTIONS |
components.rolePermissionMatrixField | default client export | Import-map path to a custom matrix Field component (client module) |
Types import from the main entry:
import type {
RBACTranslations,
PayloadPluginRBACConfig,
TargetCollection,
} from "@zealamic/payload-plugin-rbac";
Full reference: UTILS
| Function | Purpose |
|---|---|
getPermissionAccess | Unified access: permission-only, read Where, or modify per-document |
targetCollections (plugin config) | Quick ownership field + hook — COLLECTIONS |
getCreatedByRelationshipField / createCreatedByOnCreateBeforeChangeHook | Manual ownership field + hook → UTILS |
resolveUsersCollectionSlug | Same admin.user → slug resolution as the plugin |
getSuperAdminAccess | Super admin only (default on RBAC collections) |
getAuthenticatedOrSuperAdminAccess | Owner or super admin |
canAccessDocumentByDataScope | Low-level single-document RBAC + scope check |
resolveEffectiveDataScope / getHierarchyVisibleUserIds | Scope resolution |
getDataScopeReadWhere / mergeDataScopeWhere | Query filters |
getMergedFieldAffectingData / getArrayOfMergedFieldAffectingData | Field merge for overrides |
Constants: CONSTANTS.ROLE.DATA_SCOPE, CONSTANTS.PERMISSION_ACTION.TYPE, etc.
| Import | Contents |
|---|---|
@zealamic/payload-plugin-rbac | payloadPluginRBAC, utils, constants, TypeScript types |
@zealamic/payload-plugin-rbac/client | RolePermissionMatrixClient, PermissionActionReorderClient, PermissionFeatureReorderClient, createRolePermissionMatrixClient, and related types |

Reorder screenshots: Reorder overview above.
MIT
If this plugin helps your team ship safer access control with less friction, thank you for giving it a place in your stack.
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
rbac
Database-driven role-based access control with a per-collection permissions matrix and admin localization
5915/wk0v4
Payload RBAC Plugin
Database-backed roles and permissions with row-level conditions managed from the Payload admin
4939/wk6v3
payload gatekeeper
Role-based access control for Payload v3 with wildcard permissions, auto role assignment and a managed Roles collection
39199/wk25v3
payload warding
Collection-backed RBAC plugin that generates user and role collections with per-field and per-endpoint permissions
3910/wk17v2
payload plugin rbac ui
Permissions matrix UI for a Payload Roles collection with auto-discovered, validated permission strings
38172/wk1v3