CodeIgniter Forums
Best practices for simple viewing permissions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Best practices for simple viewing permissions (/thread-54354.html)



Best practices for simple viewing permissions - El Forum - 09-05-2012

[eluser]mact1079[/eluser]
I've got a small web app and the users table structure below. I've been reading up on ACL vs RBAC and while I think RBAC is the way I want to go I'm also getting a bit overwhelmed because I'm not sure if it's too much for me. I'm trying to build a solid prototype that a more advanced developer can build off of once the product/concept has been tested in the market place. For the protoype I have users and business users that need to view different pages.

1. How would you recommend me structuring my user table? Should I have a usertype field in there or is this asking for trouble? If not what is the best structure for a table(s)? Do I need to do the whole roles, permissions tables that RBAC utilizes?

2. Once I've set up user types (however I ultimately do) whats the best way of configuring my controllers so certain users can only see certain pages? Do I simply check the permissions on each controller method or do I need to do anything else in the views and models?

3. What about login functionality? Do I need to have separate login pages for each user type or should business users use the same one as regular users?

Thanks for any guidance on this. I've come a long way in building this app using CI for the first time but am feeling a little overwhelmed here. Maybe it's not so complicated...?

BTW, I'm using SimpleLoginSecure for auth.
https://github.com/DaBourz/SimpleLoginSecure


Code:
--
-- Table structure for table `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `username` varchar(16) NOT NULL,
  `email` varchar(50) NOT NULL,
  `firstName` varchar(25) NOT NULL,
  `lastName` varchar(25) NOT NULL,
  `gender` enum('male','female') NOT NULL,
  `inviteCodeUsed` varchar(10) NOT NULL,
  `passwordHash` varchar(60) NOT NULL,
  `dateCreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `dateModified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `dateLastLogin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `status` enum('active','inactive') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;