Creating roles for multiple administrators

How can create roles for multiple administrators like:

  • admin 1: can access articles and posts.
  • admin 2: can access managing users.
  • admin 3: can access another sections.

Like set privileges to every user.

I didn’t find any of articles in https://book.cakephp.org

In the CMS Tutorial there is an Authorization section.
https://book.cakephp.org/4/en/tutorials-and-examples/cms/authorization.html

But I would also recommend you watch my CakeFest talk about Authentication and Authorization

2 Likes

Thank you, I did :
https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html
and
https://book.cakephp.org/4/en/tutorials-and-examples/cms/authorization.html

but I need something like ACL in cakephp 2
set for every administrator in admin panel

  • read
  • create
  • update
  • delete

Which I mean set the values in database.

Sounds like what you’re looking for is RBAC, not ACL. The CakePHP authorization plugin doesn’t specifically include any implementation for that, but GitHub - CakeDC/users: Users Plugin for CakePHP does.

I don’t know what’s kind of plugin I need, but the goal is set permissions to every admin.

If sounds like you need three roles: “article and post admin”, “user admin” and “other admin”. If that sounds right, and if you have multiple “user admin” people, for example, then this is role-based, aka RBAC.

If you would have one admin that can manage some users, and a different admin would manage a different set of users, that’s ACL.

I did something similar to what you need. Basically, I created a database-table (let’s call it UserAccess) to store the permission (access) each user has.

Based on this ‘permission’, I use the Policy files to determine whether the user has access to that particular action.

Example assuming that my UserAccess table contains the column hasEditPermission

// snippet of Policy file example
    public function canEdit(IdentityInterface $user, Article $article)
    {
       if( $user->UserAccess->hasEditPermission ) {
         return true;
       }
    }