I am considering the best way to develop a permission system for the admin web application. There will probably be many users in the application, each of which may be assigned a specific role; some of these users may be allowed to perform certain tasks outside the role.
I can think of two ways to create this: one, with a “permissions” table with a row for each user and boolean columns, one for each task that assigns them permissions to perform these tasks. Like this:
User ID Manage Users Manage Products Manage Promotions Manage Orders
1 true true true true
2 false true true true
3 false false false true
Another way I thought was to use a bitmask to store these user permissions. This would limit the number of tasks that could be controlled to 31 for the 32-bit signed integer, but in practice we are unlikely to have more than 31 specific tasks that the user could perform. Thus, the database schema will be simpler, and we won’t have to change the table structure every time we add a new task that will require access control. Like this:
User ID Permissions (8-bit mask), would be ints in table
1 00001111
2 00000111
3 00000001
What mechanisms do people usually use, and why?
Thank!
web-applications database-design permissions
Hari Oct 13 '08 at 22:27 2008-10-13 22:27
source share