[I decided to post this as an answer because it contains code examples]
You can create a component (or function) and use the beforeFilter () callback in app_controller, so you do not need to manually add the function to all controllers.
You can also use several prefixes for actions (see Routing.prefixes in the kernel), this will simplify access control. Sort of:
[app_controller.php]
function beforeFilter() { if(isset($this->params['prefix']) && $this->params['prefix'] == 'admin'){ if(!isAdmin() || !isOwner()) $this->cakeError('error404'); } }
[users_controller.php]
function admin_edit($id = null){ ...
On the LAMP stack, your bottleneck is usually in the database
My problem with the cake is the number of requests it makes. As soon as I saw that my βcontactβ page, which made 21 requests, only to get the data structure and permissions for this public page.
The only way to justify using an ACL to access data is when permissions are dynamic, that is, "user number 29 can edit user number 12 because the administrator has resolved this in backoffice." But if you have static rules for accessing data (for example, "users can edit their own information, and administrators can edit everything"), it is useless to execute requests when you already know the answers, because these rules will not change over time .
so it all depends on your application. Finally, one final thought, if you are still planning on making more requests = P, you can set the authorization method to the Auth component . But using an ACL component for this seems like a bad idea to me.
Hooray!
source share