Skip to content

Repository files navigation

Strapi plugin - Permissions

npm version npm downloads License

This plugin is to have persistent permissions in different environments regarding api interaction.

Installation

  1. Install using npm install @gravitybv/strapi-plugin-permissions in the root of your Strapi project.

No access to @gravitybv?

If you dont have access to the @gravitybv scope you need to do the following:

  1. First you will need a personal access token (PAT)
  2. Create a toke with repo and read:packages scopes selected. Make sure to store this somehwere
  3. Run npm login --registry=https://npm.pkg.github.com --scope=gravitybv
  4. Login with your github username and use the PAT as password
  5. Now you should be able to install this package in other projects

Usage

Enable in config/plugins.js:

{
	"permissions": {
		"enabled": true
	}
}

The plugin will automatically create a file in the config/ directory of your Strapi installation. This newly created file is named config/permissions.js and will contain default permissions upon first install.

The permissions in this file will automatically be set upon Strapi bootstrap.

Naming

Please use the prefix plugin:: to target a specific plugin.

Use api:: to target one of your own controllers.

When only specifying the prefix and entity name, without targeting a controller (e.g. api::restaurant or plugin::users-permissions), the plugin will set the permissions for all of the controllers in that entity. To target a specific controller, please use: api::restaurant.restaurant, or plugin::users-permissions.auth.

Configuration

Typescript

When using in a typescript project add a config to the plugin config:

config/plugins.js

{
	"permissions": {
		"enabled": true,
		"config": {
			"typescript": true
		}
	}
}

Advanced Options

You can configure the retry behavior when waiting for Strapi to load:

config/plugins.js

{
	"permissions": {
		"enabled": true,
		"config": {
			"maxRetries": 50,
			"initialDelay": 200
		}
	}
}
  • maxRetries (default: 50): Maximum number of retry attempts before timing out
  • initialDelay (default: 200): Delay in milliseconds between retry attempts

The default configuration allows for a total wait time of 10 seconds (50 retries × 200ms)

License

MIT License

About

Permissions plugin for Strapi v4 - Permissions by config file

Resources

Stars

14 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages