I am building a web app which users use to assign tasks to each other.
The users are all on a LAN.
There is a basic permissions system already, where user roles are either Admin or normal user.
What I have to implement is something really fine-grained…and I cant think of a good way to do this
Heres a list of things I need to have control over:
- If a user can change other users info
- If the user can access the LAN network via VPN(this is another challenge all together, i think)
- Users can assign tasks to only a set of other users(maybe all, maybe few)
- If user has the ability to change/delete an already assigned task from another user
- If the user can delete other users
- If a user can change other users permissions
What I want is an example of something similar so that I dont have to re-invent the wheel. Or maybe an idea on how to implement this with as little headache as possible :P. Also I dont know how I would structure a MySQL table/s to store all these permissions.
I thought of assigning users roles but I need more flexibility than just those roles.
Any ideas?
One simple approach is to only have one extra column in the user table, called Access, Permission or something like that. Then for each of the permissions you want you define a constant with a integer value that’s dividable by 2, or the number 1, e.g:
Then when another permission level is needed you only have to add another number that’s dividable by 2, e.g. 64, 128, etc. Maybe not the prettiest solution, but a simple one.
And when you want to store permissions for a user you use the bitwise-or operator, like: