August 30, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

PHP ACL: Permissions and Performance, Page 2

  • April 11, 2012
  • By Voja Janjic
  • Send Email »
  • More Articles »

PHP ACL: Permissions and Performance

Permission names are created by you -- that means that you can use any name as a permission name. However, I suggest you check some permissions automatically and assign them some generic names, such as view_[page_name] for checking page access permissions, or form_[form_name] for checking if a certain users has permissions to submit a form.

Permission types are introduced in this version of PHP ACL, where "0" means "deny" and "1" means "allow." This feature is very useful if you have to manage exceptions, e.g., you need to allow a whole user group to execute an action, but you want to deny access to that action for a few group members.

After creating the PHP class, you need to create an object of that class in another PHP file. It should be done the following way:

<?php
$acl = new Acl();
If(!$acl->check(view_admin_dashboard,1,1)) {
// user doesn't have permission to execute the following action
//do something here
}
?>

Consider your website's performance when implementing an ACL. Using access control list checks increases the number of queries per request by 4. Although there is MySQL query cache, it is recommended that you create your own caching system. It can be as simple as storing the query results into a file and fetching them from a txt file for a certain period of time, or more complex, such as CodeIgniter's SQL caching system, which can store cache for unlimited period of time, but delete it when a certain action is executed (e.g., clear cache when a new user is registered).

In conclusion, implement the ACL model, as it is would significantly increase your website security.


Tags: PHP, security

Originally published on http://www.developer.com.

Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel