Injects a grouped checkbox permissions field into your Roles collection and validates saved values against an allow-list built from your collections and globals. Permission strings such as Create:Post are generated automatically, and manual groups can be merged in. You still add the access checks to each collection yourself, and the import map must be regenerated after install.
Reusable RBAC permissions UI and helpers for Payload CMS
Installation
npm i @salemaljebaly/payload-plugin-rbac-ui1
Stars
0
Forks
4
Open Issues
6 months ago
Last Updated
194
Weekly Downloads
v0.5.0
npm Version
60.6 KB
Unpacked Size
0
Dependencies
10 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
| Sep 6, 2026 | 1 |
183+174 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 183 |
| Dec 4, 2026 | 150 |
| Dec 3, 2026 | 121 |
| Dec 2, 2026 | 94 |
| Dec 1, 2026 | 118 |
| Nov 30, 2026 | 121 |
| Nov 29, 2026 | 89 |
| Nov 28, 2026 | 65 |
| Nov 27, 2026 | 53 |
| Nov 26, 2026 | 71 |
| Nov 25, 2026 | 103 |
| Nov 24, 2026 | 85 |
| Nov 23, 2026 | 87 |
| Nov 22, 2026 | 180 |
| Nov 21, 2026 | 348 |
| Nov 20, 2026 | 349 |
| Nov 19, 2026 | 331 |
| Nov 18, 2026 | 315 |
| Nov 17, 2026 | 309 |
| Nov 16, 2026 | 304 |
| Nov 15, 2026 | 206 |
| Nov 14, 2026 | 43 |
| Nov 13, 2026 | 41 |
| Nov 12, 2026 | 41 |
| Nov 11, 2026 | 27 |
| Nov 10, 2026 | 34 |
| Nov 9, 2026 | 46 |
| Nov 8, 2026 | 54 |
| Nov 7, 2026 | 55 |
| Nov 6, 2026 | 58 |
| Nov 5, 2026 | 61 |
| Nov 4, 2026 | 64 |
| Nov 3, 2026 | 57 |
| Nov 2, 2026 | 46 |
| Nov 1, 2026 | 54 |
| Oct 31, 2026 | 58 |
| Oct 30, 2026 | 57 |
| Oct 29, 2026 | 53 |
| Oct 28, 2026 | 43 |
| Oct 27, 2026 | 44 |
| Oct 26, 2026 | 38 |
| Oct 25, 2026 | 29 |
| Oct 24, 2026 | 18 |
| Oct 23, 2026 | 15 |
| Oct 22, 2026 | 17 |
| Oct 21, 2026 | 30 |
| Oct 20, 2026 | 31 |
| Oct 19, 2026 | 33 |
| Oct 18, 2026 | 25 |
| Oct 17, 2026 | 27 |
| Oct 16, 2026 | 36 |
| Oct 15, 2026 | 39 |
| Oct 14, 2026 | 33 |
| Oct 13, 2026 | 31 |
| Oct 12, 2026 | 35 |
| Oct 11, 2026 | 35 |
| Oct 10, 2026 | 33 |
| Oct 9, 2026 | 24 |
| Oct 8, 2026 | 19 |
| Oct 7, 2026 | 12 |
| Oct 6, 2026 | 11 |
| Oct 5, 2026 | 2 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 0 |
| Oct 2, 2026 | 0 |
| Oct 1, 2026 | 0 |
| Sep 30, 2026 | 0 |
| Sep 29, 2026 | 0 |
| Sep 28, 2026 | 0 |
| Sep 27, 2026 | 0 |
| Sep 26, 2026 | 3 |
| Sep 25, 2026 | 3 |
| Sep 24, 2026 | 3 |
| Sep 23, 2026 | 3 |
| Sep 22, 2026 | 4 |
| Sep 21, 2026 | 12 |
| Sep 20, 2026 | 12 |
| Sep 19, 2026 | 9 |
| Sep 18, 2026 | 10 |
| Sep 17, 2026 | 10 |
| Sep 16, 2026 | 11 |
| Sep 15, 2026 | 11 |
| Sep 14, 2026 | 3 |
| Sep 13, 2026 | 7 |
| Sep 12, 2026 | 8 |
| Sep 11, 2026 | 7 |
| Sep 10, 2026 | 8 |
| Sep 9, 2026 | 8 |
| Sep 8, 2026 | 8 |
| Sep 7, 2026 | 9 |
| Sep 6, 2026 | 9 |
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/1158141331-root)<a href="https://payloaddirectory.dev/plugins/1158141331-root"><img src="https://payloaddirectory.dev/badge/1158141331-root.svg" alt="Payload Directory"></a>README
RBAC permissions matrix UI for Payload CMS. Injects a grouped checkbox UI into your Roles collection and validates saved permissions against an auto-discovered allow-list.

pnpm add @salemaljebaly/payload-plugin-rbac-ui
# or
npm install @salemaljebaly/payload-plugin-rbac-ui
Create these helpers first — they are used in the collections below.
// src/access/index.ts
import type { Access } from 'payload'
/** Check if user is a super admin (bypasses all permission checks). */
export function isSuperAdmin(user: any): boolean {
return user?.superAdmin === true
}
/** Check if user has a specific permission in any of their roles. */
export function hasPermission(user: any, permission: string): boolean {
if (!user?.roles) return false
const roles = Array.isArray(user.roles) ? user.roles : [user.roles]
return roles.some((role: any) => {
const permissions = typeof role === 'object' ? role?.permissions : null
return Array.isArray(permissions) && permissions.includes(permission)
})
}
/** Use in collection access — super admins always pass, others need the permission. */
export const checkPermission =
(permission: string): Access =>
({ req: { user } }) =>
isSuperAdmin(user) || hasPermission(user, permission)
Add a superAdmin flag and a roles relationship to your Users collection:
// src/collections/Users.ts
fields: [
{
name: 'superAdmin',
type: 'checkbox',
defaultValue: false,
access: {
// Only super admins can grant super admin access
update: ({ req: { user } }) => isSuperAdmin(user),
},
admin: { description: 'Grants full access, bypasses all permission checks.' },
},
{
name: 'roles',
type: 'relationship',
relationTo: 'roles',
hasMany: true,
saveToJWT: true, // Required — without this, hasPermission() always returns false
},
]
// src/collections/Roles.ts
import type { CollectionConfig } from 'payload'
import { isSuperAdmin } from '../access'
export const Roles: CollectionConfig = {
slug: 'roles',
admin: { useAsTitle: 'name' },
access: {
read: ({ req: { user } }) => isSuperAdmin(user),
create: ({ req: { user } }) => isSuperAdmin(user),
update: ({ req: { user } }) => isSuperAdmin(user),
delete: ({ req: { user } }) => isSuperAdmin(user),
},
fields: [
{ name: 'name', type: 'text', required: true, unique: true },
{ name: 'description', type: 'textarea' },
// 'permissions' field is injected automatically by the plugin
],
}
// src/payload.config.ts
import { rbacUIPlugin } from '@salemaljebaly/payload-plugin-rbac-ui'
export default buildConfig({
collections: [Users, Roles, Posts /* ... */],
plugins: [
rbacUIPlugin({
rolesCollectionSlug: 'roles',
autoDiscover: true,
}),
],
})
After adding the plugin, run this once so Payload registers the permissions UI component:
pnpm payload generate:importmap
# or: npx payload generate:importmap
Re-run this whenever you add or remove Payload plugins with custom UI.
The plugin does not protect your collections automatically. You must add
checkPermission(orisSuperAdmin) to every collection you want to gate. Any collection without a customaccessrule remains visible and accessible to all authenticated users.Not sure what string to pass? Complete the first setup (step 7), then open any Role in the admin UI — all generated permission strings are listed there.
Apply to every collection — including Media:
// src/collections/Posts.ts
import { checkPermission } from '../access'
access: {
create: checkPermission('Create:Post'),
read: checkPermission('Read:Post'),
update: checkPermission('Update:Post'),
delete: checkPermission('Delete:Post'),
}
No one has superAdmin: true yet, so no one can access the Roles collection. Bootstrap by adding a temporary seed route:
// src/app/seed/route.ts — REMOVE IN PRODUCTION
import configPromise from '@payload-config'
import { getPayload } from 'payload'
export const GET = async () => {
const payload = await getPayload({ config: configPromise })
const { docs } = await payload.find({ collection: 'users', limit: 1, sort: 'createdAt' })
if (!docs[0]) return Response.json({ error: 'Create an account first.' }, { status: 404 })
await payload.update({
collection: 'users',
id: docs[0].id,
data: { superAdmin: true } as any,
overrideAccess: true,
})
return Response.json({ message: 'Done! Log out and back in.', email: docs[0].email })
}
/admin/create-first-userhttp://localhost:3000/seed — your account is now superAdminThe re-login step is required — the
superAdminflag is read from the JWT on each request.
| Type | Slug | Generated strings |
|---|---|---|
| Collection | posts | Create:Post, Read:Post, Update:Post, Delete:Post |
| Collection | categories | Create:Category, Read:Category, … |
| Global | settings | Read:Global:Setting, Update:Global:Setting |
Rule: slug → singularize → PascalCase. Open the Roles admin UI to see the exact strings for your app.
rbacUIPlugin({
autoDiscover: true,
permissionGroups: [
{
label: 'Post',
permissions: [
{ action: 'Publish', description: 'Publish posts', permission: 'Publish:Post' },
],
},
],
})
Auto-discovered and manual groups with the same label are merged.
| Option | Default | Description |
|---|---|---|
rolesCollectionSlug | 'roles' | Slug of your roles collection |
permissionsFieldName | 'permissions' | Field name to inject/patch |
permissionGroups | [] | Manual permission groups |
autoDiscover | false | true or config object (see below) |
rolesFieldDescription | — | Description shown under the field |
ensurePermissionsField | true | Auto-add field if missing. Set false to skip |
customFieldPath | — | Override the React component path |
onConfigureRolesCollection | — | Callback to modify the final collection config |
autoDiscover options| Option | Default | Description |
|---|---|---|
collections | true | Discover from collections |
globals | true | Discover from globals |
collectionActions | ['Create','Read','Update','Delete'] | Actions per collection |
globalActions | ['Read','Update'] | Actions per global |
includeRolesCollection | true | Include the roles collection itself. Set false to exclude — permissions like Create:Role won't be in the allow-list, so don't use them in seed data |
formatPermission(ctx) | — | ctx: { action: string, slug: string, source: 'collection' | 'global' } → string |
formatGroupLabel(ctx) | — | ctx: { slug: string, source: 'collection' | 'global' } → string |
^3.76.1^19>=15.2.9 <15.3.0 || >=15.3.9 <15.4.0 || >=15.4.11 <15.5.0 || >=16.2.0-canary.10 <17.0.0pnpm install
pnpm build
pnpm typecheck
pnpm test
main.pnpm build && pnpm typecheck && pnpm test.See CONTRIBUTING.md for details.
pnpm version patch # or minor / major
pnpm publish --access public
git tag -a vX.Y.Z -m "Release vX.Y.Z"
git push origin vX.Y.Z
payload access plugin
Editable roles and an access matrix for per-collection, global and field permissions in the Payload admin
350v3
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
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
rbac
Role and capability engine with inheritance, wildcards and access guards for collections and fields
67737/wk0v3
rbac
Database-driven role-based access control with a per-collection permissions matrix and admin localization
5915/wk0v4
payload plugin rbac
Database-driven role-based access control with a permission matrix and data scopes for Payload collections
5874/wk10v3