Orelo-Software

payload default roles

by Orelo-Software
Roles & permissions
v1
^1.2.1

Overview

Summary generated from the README

Adds default access control to every collection in a Payload config based on a list of roles. By default access is granted to the admin and executive roles, and the roles can be changed through options. Specific collections can be excluded by slug. It is registered as a plugin in the Payload config and targets Payload 1.x.

Features

  • Applies default access rules to all collections at once
  • Configurable list of roles, defaulting to admin and executive
  • Option to ignore selected collections by slug
  • Works with no arguments using sensible defaults

Use cases

  • Lock down every collection to admin roles without writing access functions for each one
  • Apply a consistent baseline role policy while exempting user or auth collections

From the author

Adds default access permissions to all collections

Installation

npm i @orelo/payload-default-roles

9

Stars

0

Forks

5

Open Issues

3 years ago

Last Updated

0

Weekly Downloads

v0.0.6

npm Version

8.1 KB

Unpacked Size

0

Dependencies

GitHub stars

Trends appear after 7 days of data. Daily snapshots have not started yet.

npm weekly downloads

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

20/100Poor

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/571944068-root.svg)](https://payloaddirectory.dev/plugins/571944068-root)
HTML
<a href="https://payloaddirectory.dev/plugins/571944068-root"><img src="https://payloaddirectory.dev/badge/571944068-root.svg" alt="Payload Directory"></a>
Updated Oct 4, 2023Created Nov 29, 2022Published Dec 1, 2022

README

Payload Default Roles

Add default roles for access control on all collections.

Options

  • ignoredSlugs: string[] Optional

    An array of the slugs from the collections this plugin should leave untouched.

  • roles: string[] Optional

    An array of the roles this plugin should default access to.
    Default: ["admin", "executive"]

Example

// payload.config.ts
import { buildConfig } from 'payload/config';
import { defaultAccess } from '@orelo/payload-default-roles';

export default buildConfig({
  plugins: [
    defaultAccess(), // Pass nothing to use the default options
  ],
});

Example with Options

export default buildConfig({
  plugins: [
    defaultAccess({
      ignoredSlugs: ['cms-user', 'admin'],
      roles: ['administrator', 'moderator'],
    }),
  ],
});

Similar plugins