Access control list to manage the database column that is retrieved

I have a site created in codeigniter for which I created an access control list to manage permissions for different types of users. The users registered on the site are:

  • Super admin
  • Administrator
  • SEO user
  • Developer

Now I have completed access control for this, and the permission to add, update, list and delete can be assigned to each user through the module available for Super Admin.

Now (this is part of the new client requirement) I want the columns to be accessible to specific users, for example:

If the Products table has 4 columns

Products : id | Products | Price | Status -----+-----------+-------+---------- 1 | prod1 | 20.0 | 1 2 | prod2 | 35.6 | 0 

Now I want for users of SEO Column Price not to be displayed during listing.

NOTE. This is just an example, I need to make this dynamic so that the administrator controls who has permission to which column. I can't just write If Else logic in my View file to exclude unwanted columns.

Please tell me how I can do this without changing the entire system or making major changes.

+7
php mysql codeigniter acl
source share
3 answers

You can use the ion_auth library. It is very easy to integrate and manage users and access levels ...

+1
source share

This is why you use ACLs. ACLS is a dynamic way to store privileges. Hope you have a user model. In this model, you need to read the ACL for the current user. you set some constants for the access level, similar to unix chmod. then you create an array with contains all the columns and the acl value for that column.

To create your queries, you can use methods such as

 isSeo(); 

or

 hasAccess($tableName); 

Of course, this is a major change, but I don’t know how you want to implement ACLs that change your code.

0
source share

Maybe try a stored procedure / functions or try using the original SQL like this

 GRANT SELECT(id,Products,Status) ON Products TO 'SEO User'@'somehost'; 
0
source share

All Articles