CodeIgniter Forums
Best practice for managing site roles and permissions? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Best practice for managing site roles and permissions? (/showthread.php?tid=49030)



Best practice for managing site roles and permissions? - El Forum - 02-06-2012

[eluser]Unknown[/eluser]
I have a site I am working on that will have various pages that are access controlled based on user logins and role groups, where different groups will have access to certain pages and some of the same pages with slight modifications. Wondering what is the best practice for implementing this.

My planned approach is to separate my site into 3 controllers for the 3 roles I have and assign a session for each logged in user. Then I can check their role in each controller constructor and redirect to the appropriate controller or login page where necessary. There is a fourth role that will share MOST of the same functionality and page access so for these two I would implement checks to tweak the view as needed.

Any comments or suggestions on this approach would be great. Thanks!


Best practice for managing site roles and permissions? - El Forum - 02-07-2012

[eluser]PhilTem[/eluser]
As long as you'll stick with these four roles maximum, you can use some hard-coded permission checking. Setting the groups in hierarchical order with even unix-styled group ids (id = 1, 2, 4, 8, 16, ...) can come in handy for easier permission checking.

But as soon as you want to have more dynamic permissions and roles it's probably easier to use some ACL (access control list). There are some threads around this forum you might wanna have an eye on.