Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you restrict access to parts of strapi admin?

Tags:

strapi

Using Strapi to build an API. Love most of it, but it seems access to the admin interface is all or nothing; you can't hide the more advanced aspects of admin for users who should only be able to add/edit content...? Am I missing something? How is this done?

like image 807
user2654408 Avatar asked Mar 31 '18 19:03

user2654408


1 Answers

Actually you can change some things, since there is an /admin folder inside of /node_modules that you can overwrite, as the documentation says here, you can overwrite some logic for specific users and specific cases, that's not the best way to do it, but it's what we have for now.

Example: In my project I don't want any user to access the Content-Types Builder on production, at the end, I decided to hide the entire Plugins section on production environment.

So firstly I copied the entire /admin folder inside of my project, that way it'd be simple to find/edit any component.

Secondly I searched were the sections where rendered, and I found this file:

/my-project/admin/src/components/LeftMenuLinkSection/index.js

And I added this inside of the component:

const LeftMenuLinksSection = ({ section,
  ....
  // before the return
  if ( section === 'plugins' && process.env.NODE_ENV !== 'development') return null;;

And it worked, on production I don't have the plugins section on admin left menu (image 1):

It depends what you want to do, that could be possible, so it's not "all or nothing", it's more like all or almost nothing.

left admin menu on production

like image 150
Lucas Andrade Avatar answered Oct 19 '22 17:10

Lucas Andrade