Coder Social home page Coder Social logo

alan2207 / strapi-plugin-sync-roles-permissions Goto Github PK

View Code? Open in Web Editor NEW
39.0 3.0 4.0 744 KB

Store user roles and permissions configuration as a JSON file and then import and reuse it any time.

License: MIT License

JavaScript 100.00%
strapi-plugin strapi strapi-cms strapi-admin-panel roles-permission-management

strapi-plugin-sync-roles-permissions's Introduction

strapi-plugin-sync-roles-permissions

NPM

Store user roles and permissions configuration as a JSON file and then import and reuse it any time.

Admin

Motivation

Sometimes our applications require lots of different types of users with a lot of different permissions. Strapi with it's strapi-plugin-users-permissions gives us a lot of functionalities out of the box, which is great. However, it would be nice to be able to store the roles and permissions configuration in order to be able to share it across multiple instances of the application. It is especially useful during development so we don't have to configure it every time we clear the db.

With this plugin we can export existing roles and permissions configuration as a JSON file at any point of time, and then whenever we need to update the application with the given configuration we can just upload the same JSON file and roles and permissions will be synced in the db.

Installation

1.

This plugin is built on top of the official strapi-plugin-users-permissions plugin, so make sure it is already enabled.

2.

Install with npm:

npm install --save strapi-plugin-sync-roles-permissions
npm run build

Install with yarn:

yarn add strapi-plugin-sync-roles-permissions
yarn build

4.

Start your strapi server.

Usage

  1. If you have a new application, configure all your roles and permissions from roles section in settings of the admin panel.

  2. Then you can export your roles and permissions into a JSON file and store it somewhere.

  3. Then any time you want to populate your db with the exported roles and permissions configuration, you can do that by importing the JSON file and update roles and permissions.

  4. The same proccess can be repeated any time you want to save your current roles and permissions configuration. Your roles configuration in the db will be overriden with the one from the JSON file.

LICENSE

MIT

strapi-plugin-sync-roles-permissions's People

Contributors

alan2207 avatar ghostspook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

strapi-plugin-sync-roles-permissions's Issues

Use this programatically

Hi,

I just wrote something similar to this, but to be used on server first run. I haven't check the json structure, sure it's different because I made up mine to my (simple) needs.

Anyhow, I guess I'd be able to call the updateRoles using something like:

strapi.query('sync-roles-permissions').update(myJsonObject);

but would be great to have a working example in the readme together with a json structure example :)

Thanks for the plugin, great work!

Get a 401 Unauthorized response for /sync-roles-permissions/roles

When I click on the Export Roles And Permissions button I get a 401 Unauthorized response. The UI then logs me out and prompts me for the Ui.

imagen

imagen

How to reproduce the error:

I have strapi running in a docker setup.

  1. Install strapi using docker according to oficial documentation:
    https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/installation/docker.html
  2. When the app is built, visit localhost:1337/admin, create an admin user, create a simple content-type (say article) and give the Authenticated Role some permissions on that new content-type.
  3. Using docker desktop, open a CLI terminal
    imagen
  4. Install the plugin and rebuild using the plug-in instructions:
    https://github.com/alan2207/strapi-plugin-sync-roles-permissions#installation
  5. When it's done, restart the docker app.
  6. Login with as the admin user and try to export using the Export Roles and Permissions button.

UPDATE: I just noticed that, after installing the plugin using npm (as per instructions) there are only 2 files modified in my project: package.json and package-lock.json. I see no additional folders/files in the ./app/api folder. So I suppose the 401 Unauthorized error is due to the fact that the required API is not properly setup. Am I wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.