Adds a role field to chosen auth collections and applies per-operation access rules to collections and globals from a single plugin config. Roles are listed in order of priority, so higher roles inherit the access of lower ones. Built for Payload 1.x and marked as beta by the author.
PayloadCMS plugin to help handle simple RBAC permissions.
Installation
npm i @nouance/payload-simple-rbac40
Stars
1
Forks
2
Open Issues
2 years ago
Last Updated
27
Weekly Downloads
v0.2.0
npm Version
31.3 KB
Unpacked Size
0
Dependencies
400 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 40 |
| Dec 5, 2026 | 40 |
| Dec 4, 2026 | 40 |
| Dec 3, 2026 | 40 |
| Dec 2, 2026 | 40 |
| Dec 1, 2026 | 40 |
| Nov 30, 2026 | 40 |
| Nov 29, 2026 | 40 |
| Nov 28, 2026 | 40 |
| Nov 27, 2026 | 40 |
| Nov 26, 2026 | 40 |
| Nov 25, 2026 | 41 |
| Nov 24, 2026 | 41 |
| Nov 23, 2026 | 41 |
| Nov 22, 2026 | 41 |
| Nov 21, 2026 | 41 |
| Nov 20, 2026 | 41 |
| Nov 19, 2026 | 41 |
| Nov 18, 2026 | 41 |
| Nov 17, 2026 | 41 |
| Nov 16, 2026 | 41 |
| Nov 15, 2026 | 41 |
| Nov 14, 2026 | 41 |
| Nov 13, 2026 | 41 |
| Nov 12, 2026 | 41 |
| Nov 11, 2026 | 41 |
| Nov 10, 2026 | 41 |
| Nov 9, 2026 | 41 |
| Nov 8, 2026 | 41 |
| Nov 7, 2026 | 41 |
| Nov 6, 2026 | 41 |
| Nov 5, 2026 | 41 |
| Nov 4, 2026 | 41 |
| Nov 3, 2026 | 41 |
| Nov 2, 2026 | 41 |
| Nov 1, 2026 | 41 |
| Oct 31, 2026 | 41 |
| Oct 30, 2026 | 41 |
| Oct 29, 2026 | 41 |
| Oct 28, 2026 | 41 |
| Oct 27, 2026 | 41 |
| Oct 26, 2026 | 41 |
| Oct 25, 2026 | 41 |
| Oct 24, 2026 | 41 |
| Oct 23, 2026 | 41 |
| Oct 22, 2026 | 41 |
| Oct 21, 2026 | 40 |
| Oct 20, 2026 | 40 |
| Oct 19, 2026 | 40 |
| Oct 18, 2026 | 40 |
| Oct 17, 2026 | 40 |
| Oct 16, 2026 | 40 |
| Oct 15, 2026 | 40 |
| Oct 14, 2026 | 40 |
| Oct 13, 2026 | 40 |
| Oct 12, 2026 | 40 |
| Oct 11, 2026 | 40 |
| Oct 10, 2026 | 40 |
| Oct 9, 2026 | 40 |
| Oct 8, 2026 | 40 |
| Oct 7, 2026 | 40 |
| Oct 6, 2026 | 40 |
| Oct 5, 2026 | 40 |
| Oct 4, 2026 | 40 |
| Oct 3, 2026 | 40 |
| Oct 2, 2026 | 40 |
| Oct 1, 2026 | 40 |
| Sep 30, 2026 | 40 |
| Sep 29, 2026 | 40 |
| Sep 28, 2026 | 40 |
| Sep 27, 2026 | 40 |
| Sep 26, 2026 | 40 |
| Sep 25, 2026 | 40 |
| Sep 24, 2026 | 40 |
| Sep 23, 2026 | 40 |
| Sep 22, 2026 | 40 |
| Sep 21, 2026 | 40 |
| Sep 20, 2026 | 40 |
| Sep 19, 2026 | 40 |
| Sep 18, 2026 | 40 |
| Sep 17, 2026 | 40 |
| Sep 16, 2026 | 40 |
| Sep 15, 2026 | 40 |
| Sep 14, 2026 | 40 |
| Sep 13, 2026 | 40 |
| Sep 12, 2026 | 40 |
| Sep 11, 2026 | 40 |
| Sep 10, 2026 | 40 |
| Sep 9, 2026 | 40 |
| Sep 8, 2026 | 40 |
| Sep 7, 2026 | 40 |
27+8 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 27 |
| Dec 5, 2026 | 27 |
| Dec 4, 2026 | 18 |
| Dec 3, 2026 | 21 |
| Dec 2, 2026 | 16 |
| Dec 1, 2026 | 20 |
| Nov 30, 2026 | 16 |
| Nov 29, 2026 | 22 |
| Nov 28, 2026 | 22 |
| Nov 27, 2026 | 19 |
| Nov 26, 2026 | 19 |
| Nov 25, 2026 | 16 |
| Nov 24, 2026 | 13 |
| Nov 23, 2026 | 13 |
| Nov 22, 2026 | 7 |
| Nov 21, 2026 | 7 |
| Nov 20, 2026 | 7 |
| Nov 19, 2026 | 6 |
| Nov 18, 2026 | 15 |
| Nov 17, 2026 | 14 |
| Nov 16, 2026 | 14 |
| Nov 15, 2026 | 12 |
| Nov 14, 2026 | 12 |
| Nov 13, 2026 | 12 |
| Nov 12, 2026 | 10 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 7 |
| Nov 9, 2026 | 7 |
| Nov 8, 2026 | 13 |
| Nov 7, 2026 | 13 |
| Nov 6, 2026 | 13 |
| Nov 5, 2026 | 15 |
| Nov 4, 2026 | 16 |
| Nov 3, 2026 | 10 |
| Nov 2, 2026 | 10 |
| Nov 1, 2026 | 4 |
| Oct 31, 2026 | 5 |
| Oct 30, 2026 | 5 |
| Oct 29, 2026 | 3 |
| Oct 28, 2026 | 2 |
| Oct 27, 2026 | 9 |
| Oct 26, 2026 | 10 |
| Oct 25, 2026 | 9 |
| Oct 24, 2026 | 8 |
| Oct 23, 2026 | 8 |
| Oct 22, 2026 | 11 |
| Oct 21, 2026 | 13 |
| Oct 20, 2026 | 6 |
| Oct 19, 2026 | 8 |
| Oct 18, 2026 | 9 |
| Oct 17, 2026 | 11 |
| Oct 16, 2026 | 11 |
| Oct 15, 2026 | 8 |
| Oct 14, 2026 | 18 |
| Oct 13, 2026 | 18 |
| Oct 12, 2026 | 15 |
| Oct 11, 2026 | 15 |
| Oct 10, 2026 | 13 |
| Oct 9, 2026 | 14 |
| Oct 8, 2026 | 14 |
| Oct 7, 2026 | 3 |
| Oct 6, 2026 | 3 |
| Oct 5, 2026 | 3 |
| Oct 4, 2026 | 2 |
| Oct 3, 2026 | 2 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 0 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 7 |
| Sep 25, 2026 | 7 |
| Sep 24, 2026 | 7 |
| Sep 23, 2026 | 7 |
| Sep 22, 2026 | 7 |
| Sep 21, 2026 | 13 |
| Sep 20, 2026 | 13 |
| Sep 19, 2026 | 7 |
| Sep 18, 2026 | 7 |
| Sep 17, 2026 | 8 |
| Sep 16, 2026 | 9 |
| Sep 15, 2026 | 9 |
| Sep 14, 2026 | 4 |
| Sep 13, 2026 | 7 |
| Sep 12, 2026 | 10 |
| Sep 11, 2026 | 12 |
| Sep 10, 2026 | 14 |
| Sep 9, 2026 | 17 |
| Sep 8, 2026 | 18 |
| Sep 7, 2026 | 19 |
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/616924057-root)<a href="https://payloaddirectory.dev/plugins/616924057-root"><img src="https://payloaddirectory.dev/badge/616924057-root.svg" alt="Payload Directory"></a>README
Needs more testing!
A plugin for Payload CMS to provide a baseline to help handle user roles and permissions.
yarn add @nouance/payload-simple-rbac
# OR
npm i @nouance/payload-simple-rbac
On the face of it, this plugin only aims to get you up and started with some form of Role-Based Access Control.
You create an array of roles in order of priority with the latter being the most important, for example this means that an admin can do everything an editor can and more but an editor will be limited to their level of access.
In the plugins array of your Payload config, call the plugin with options:
import { buildConfig } from "payload/config";
import payloadSimpleRBAC, { starterRoles } from "@nouance/payload-simple-rbac";
const config = buildConfig({
// ... rest of my config
plugins: [
payloadSimpleRBAC({
roles: starterRoles,
users: [Users.slug],
defaultRole: "editor", // set a default
collections: [
{
slug: Posts.slug,
permissions: {
read: "publishedOnly",
update: "editor",
create: "editor",
delete: "manager",
},
},
],
}),
],
});
export default config;
Roles
Array | Required
An array of roles as strings in order of priority, roles at the end have a higher priority.
users
Array | Required
An array of user slugs to attach the role field to.
defaultRole
String | Required
Set the default role for users to have.
fieldName
String | Optional | Defaults to role
Allows you to configure the machine name of the role field to avoid conflicts.
collections
Array | Optional
Must contain the following
Stringread | update | create | deleteglobals
Array | Optional
Must contain the following
Stringread | updaterole
This is your custom role name, any user with the same role or higher will pass this permission.
publishedOnly
Allow access only to published content, based on Payload's draft system. So your collection must have it enabled.
public
This allows full public access. The actual function is
publicAccess = () => true;
import { starterRoles } from "@nouance/payload-simple-rbac";
// ...
roles: starterRoles,
// ...
starterRoles is an array containing 3 roles, editor | manager | admin .
We've exposed our internal functions in case you want to use them in your own code or in combination with other access controls.
hasRole
Takes in your target role and full list of roles.
read: hasRole("editor", myRoles);
hasRoleField
Takes in your target role and full list of roles. Specifically used for field access control.
{
name: "metadata",
type: "json",
access: {
read: hasRoleField("admin", myRoles),
},
},
publicAccess
Anyone can pass this access control.
read: publicAccess();
publishedOnly
Any logged in user can pass this access control, non-authenticated requests can only pass published checks. You can also pass an array of strings for auth collection slugs to limit the auth'd access only to a specific set of users.
read: publishedOnly();
// limited to 'user' collection slug, other auth collections will not pass
read: publishedOnly(["user"]);
import { buildConfig } from "payload/config";
import payloadSimpleRBAC from "@nouance/payload-simple-rbac";
const config = buildConfig({
plugins: [
payloadSimpleRBAC({
roles: ["customer", "editor", "manager", "admin"],
users: [Users.slug],
defaultRole: "customer",
collections: [
{
slug: Posts.slug,
permissions: {
read: "publishedOnly",
update: "editor",
create: "editor",
delete: "manager",
},
},
{
slug: Categories.slug,
permissions: {
read: "public",
},
},
{
slug: Tags.slug,
permissions: {
read: "publishedOnly",
create: "manager",
update: "manager",
delete: "admin",
},
},
],
}),
],
});
export default config;
For development purposes, there is a full working example of how this plugin might be used in the demo of this repo:
git clone [email protected]:NouanceLabs/payload-simple-rbac.git \
cd payload-simple-rbac && yarn \
cd demo && yarn \
cp .env.example .env \
vim .env \ # add your creds to this file
yarn dev
rbac
Database-stored roles with a per-collection CRUD permission matrix enforced across all collections and globals
61205/wk16v3
rbac
Role-based access control with ready-made, composable access functions and query filters for Payload collections
4899/wk143v1
payload default roles
Apply default role-based access permissions to every collection in one plugin call
2722/wk9v1
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
payload plugin sharing
Share records with users and organizations through groups with Owner, Manager and Viewer levels
76425/wk0v3
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