Adds a roles collection and a roles field on users so admins can define who may read, create, update, delete and publish each collection and global, and which fields are hidden or read-only, without a deploy. It wraps access functions so the final result is your own rule combined with the role, and adds an Access matrix screen at the admin route. Requires Payload 3.90 or later, and the import map must be regenerated.
Editable roles and an access matrix for Payload CMS
Installation
npm i payload-access-plugin0
Stars
0
Forks
0
Open Issues
Today
Last Updated
0
Weekly Downloads
v
npm Version
Dependencies
00 since Nov 29
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| 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 |
Trends appear after 7 days of data. Daily snapshots have not started yet.
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/1483093820-root)<a href="https://payloaddirectory.dev/plugins/1483093820-root"><img src="https://payloaddirectory.dev/badge/1483093820-root.svg" alt="Payload Directory"></a>README
Editable roles and an access matrix for Payload 3. Admins create roles and decide who can read, create, update, delete and publish each collection and global, and which fields are hidden or read-only, without a deploy. The app sets the guardrails in code.
GET /api/access-plugin/me and GET /api/access-plugin/schema endpoints.npm install payload-access-plugin
# or
pnpm add payload-access-plugin
# or
bun add payload-access-plugin
Peer dependency: payload ^3.90.0.
import { buildConfig } from 'payload'
import { accessPlugin } from 'payload-access-plugin'
export default buildConfig({
// collections: [Users, Posts, ...]
plugins: [
accessPlugin({
roles: { seed: [{ name: 'Admin', slug: 'admin', locked: true, permissions: {} }] },
superAdmin: (user) => user?.roles?.some((role) => role?.slug === 'admin') ?? false,
}),
],
})
Then run payload generate:importmap so the admin panel finds the plugin's components. The plugin adds a roles collection and a roles field on your users collection, and an Access screen at /admin/access.
Create the first admin user and give them the admin role right away (see the first-user note under Limitations and notes).
Every option is optional. All are passed to accessPlugin(options).
| Option | Type | Default | Meaning |
|---|---|---|---|
enabled | boolean | true | When false, the roles collection and the users field stay, and so do the role guardrails and the manageRoles gate on the roles collection. Only the collection, global and field restrictions, the Access screen and the endpoints are off. |
users | CollectionSlug | CollectionSlug[] | the admin user collection (admin.user) | Auth collections that get a roles field. Throws if a slug is not in the config. |
roles.slug | string | 'roles' | Slug of the roles collection. |
roles.overrides | (collection: CollectionConfig) => CollectionConfig | none | Adjust the roles collection before it is registered. |
roles.seed | RoleSeed[] | [] | Roles created on init when no role with that slug exists. Existing roles are never overwritten. |
govern.collections | true | CollectionSlug[] | { include?: CollectionSlug[]; exclude?: CollectionSlug[] } | every collection except the roles collection and payload-* collections | Collections that appear in the matrix and are enforced. |
govern.globals | true | GlobalSlug[] | { include?: GlobalSlug[]; exclude?: GlobalSlug[] } | every global except payload-* globals | Globals that appear in the matrix and are enforced. |
govern.fields | boolean | Record<string, string[]> | every named field | Field-level rows. false turns them off. A record lists dotted field paths per collection or global slug. |
actions | { name: string; label: string; appliesTo?: string[] }[] | [] | App-defined actions shown in the matrix. appliesTo lists governed slugs and defaults to all. Check them with can(). |
ownership | { field: string } | Record<CollectionSlug, string> | none | Enables the own scope. One field name for every governed collection, or a field name per collection. |
superAdmin | (user) => boolean | () => false | Users for whom this returns true bypass the matrix. They never bypass the app's own access rules. |
manageRoles | (user) => boolean | the superAdmin function | Who may edit roles, assign them and see the matrix. |
locks | Lock[] | [] | Code-level values the matrix shows and cannot change. Locks win over role data. |
defaultRoles | string[] | [] | Role slugs given to a new user when none are set. |
cache.ttlSeconds | number | 30 | How long role lookups stay in the process cache. |
admin.group | string | none (top-level link) | Nav group for the Access link. |
admin.path | string | '/access' | Route of the matrix screen under the admin route. |
admin.label | string | the translated "Access" label | Nav link label. |
i18n | Partial<Translations> | {} | Override any string the screens show. English is the default. |
manageRoles and superAdmin receive the user with its roles populated, so you can compare role slugs. Both run on every request.
Lock is { roles: '*' | string[]; target: string; action: string; value: 'allow' | 'deny' | 'own' }. target is a collection or global slug, or '*'. Locks apply in array order and later locks override earlier ones for the same cell.
RoleSeed is { name: string; slug: string; permissions: RolePermissions; description?: string; locked?: boolean }. RolePermissions is { collections?, globals?, fields?, custom? }. For example:
{
collections: { posts: { read: 'all', update: 'own' } },
globals: { settings: { read: 'all' } },
fields: { posts: { internalNotes: 'hidden' } },
}
Scopes are 'all', 'own' or 'none'. Field rules are 'hidden' or 'readOnly'. Built-in actions:
read, create, update, delete. readVersions when versions are on. publish when drafts are on.read, update. readVersions when versions are on. publish when drafts are on.Exports: accessPlugin, can(req, target, action), getPermissions(req) and the types AccessPluginOptions, CustomAction, Lock, RoleSeed and Translations from payload-access-plugin. The admin components come from payload-access-plugin/client and payload-access-plugin/rsc.
See docs/recipes.md for worked examples.
final = appAccess AND roleAccess. Booleans and Where results combine (both wheres are joined with and). A role grants only what your own rules already allow, never more. Missing app access counts as Payload's default (signed in).all over own over none). A field is hidden or read-only only if every role says so.superAdmin skips the matrix. The app's own access functions still apply.manageRoles cannot change anyone's roles, their own included.manageRoles but is not a super admin cannot make anyone a super admin, themselves included. A roles change that newly gives a user a super-admin role is refused with a 403 ("Only a super admin can grant a super-admin role."). Calls without a signed-in user and calls with overrideAccess (seeds, the first user) are trusted./admin/access (change it with admin.path). Rows are collection and action, columns are roles. Click a cell to cycle none, all and own (own only where ownership is configured). Locked cells show why they are locked. Filter by group or role, or show only differences. Changes save together after a summary of what will change.The nav link, and the schema it reads, are only for users who pass manageRoles. Roles keep their normal list and edit views, and the roles collection is versioned, so you can audit changes.
Both are mounted under Payload's API route (/api by default). Neither exists when enabled is false.
GET /api/access-plugin/meThe signed-in user's merged permissions, for front ends.
200:
{
"roles": ["editor"],
"superAdmin": false,
"collections": { "posts": { "read": "all", "update": "own", "publish": "none" } },
"globals": { "settings": { "read": "all", "update": "none" } },
"fields": { "posts": { "internalNotes": "hidden" } },
"custom": []
}
Scopes are all, own or none. fields lists only fields with a rule and is empty for super admins. custom is the role's free-form custom entries.
401: { "errors": [{ "message": "You must be signed in." }] }
GET /api/access-plugin/schemaWhat the matrix shows. Only for users who pass manageRoles.
200:
{
"rolesSlug": "roles",
"targets": {
"posts": {
"kind": "collection",
"label": "Posts",
"group": "Content",
"actions": [{ "name": "read", "label": "Read" }],
"fields": [{ "path": "title", "label": "Title" }]
}
},
"customActions": [{ "name": "export", "label": "Export" }],
"locks": [],
"ownership": ["posts"]
}
ownership lists the slugs that have an owner field. group is present when the collection or global has an admin.group.
401: not signed in (same body as above).
403: { "errors": [{ "message": "You are not allowed to manage roles." }] }
Payload's own /api/access keeps working and reflects the wrapped rules.
govern.collections (for example { exclude: ['users'] }) or give every role a users permission.cache.ttlSeconds (default 30 seconds). The instance that saves the role sees it at once.can() reports the role scope only. It does not run your collection's own access rules. Use it for custom actions and UI hints, not as the only check on a document.roles array on create counts as no roles and gets defaultRoles.admin.group equal to an existing nav group label renders a second group with the same name.| payload-access-plugin | Payload | Database adapters tested |
|---|---|---|
| 0.1.x | ^3.90.0 | SQLite, Postgres, MongoDB |
CI runs the integration tests on Payload 3.90.0 and 3.94.2 against all three adapters. Payload 4 is not supported yet.
Payload 3.90.0 is the minimum because earlier 3.x releases do not pass the incoming data to collection update access on bulk (where-based) updates, so the plugin could not enforce the publish permission there, and before 3.88.0 a user could sort by a field their role hides. Node ^22.23.5 || ^24.22.3 || >=26.13.1.
Use bun.
bun install
bun run dev # dev app with the plugin
bun run test:int # integration tests (vitest)
bun run test:e2e # Playwright, including axe checks
bun run lint
bun run typecheck
bun run build
TEST_DB selects the database for the integration tests and the dev app:
sqlite (default): file dev/test.db, recreated for every test run.postgres: uses DATABASE_URL.mongodb: starts an in-memory replica set.For example, TEST_DB=mongodb bun run test:int. The e2e tests run with TEST_DB=sqlite after bun run generate:importmap.
Add a changeset for any user-facing change with bun run changeset. Releases are cut by the release workflow when the version pull request is merged.
MIT
Tags
rbac
Role and capability engine with inheritance, wildcards and access guards for collections and fields
67737/wk0v3
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
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