Default Roles
Applies default role-based access control to every Payload collection, granting CRUD access to specified roles such as admin and executive.
Installation
pnpm add @orelo/payload-default-roles About
Default Roles is a small Payload plugin that fills in access permissions for collections that do not define their own. It iterates over every collection in your config and assigns a default access function to create, update, delete, read, readVersions, and unlock, unless a collection already specifies its own rules for that operation. The default function checks the authenticated user's `role` field against a configurable list of allowed roles. By default those roles are `admin` and `executive`. You can pass a custom `roles` array to match whatever role values your users collection uses. A `ignoredSlugs` option lets you skip specific collections entirely so their access config stays untouched. The plugin targets Payload 1.x and expects your users collection (the one named in `admin.user`, defaulting to `user`) to have a top-level field named `role`. On startup it validates that field exists and throws if it is missing, which is worth knowing if you build the users collection dynamically or rename the field. It is a thin wrapper around the Payload plugin interface, so existing explicit access rules on a collection take precedence because they are spread after the defaults.
Package info
- Package name
@orelo/payload-default-roles- Latest version
0.0.6- Unpacked size
- 8 kB
- License
- MIT
- Weekly downloads
- 1
- Last publish
- Dec 1, 2022
Similar plugins
More in Authauth plugin
Adds authentication capabilities to Payload CMS.
oAuth plugin
Integrates OAuth authentication into Payload CMS using passport-oauth2.
RBAC permissions UI
Adds a permissions management UI for roles in Payload CMS.
Masquerade
Masquerade user for Payload CMS.
RBAC
Add role-based access control features to Payload CMS.
Better Auth
Better Auth adapter and plugins for Payload CMS.