hmm, there's a number of things. I do them automatically now, so it's just a matter of thinking of them. I'll post this to the main board as well.
This looks like it's going to be big, so here's a summary. I'll start off by giving an example on where security levels won't be sufficient and why. I'll then move on to alternatives. This is an expansion and contination of my previous post.
outline:
- example
- analysis
- template users
- groups
I remember HDM (Hard Disk Menu... that really old dos menu system) had security levels in it. The trouble I found with it was that it was well suited to small numbers of users and a small number of levels of users. It did support 99 levels, but managing who had superiority over who became a huge issue. This way of thinking implies a linear way of thinking. Ie peolpe at the bottom only want to do one thing (... no comment 😉 ) and gradually as ranks get higher, responsibilities are slowly added up.
The reason I dislike this way of thinking is because it doesn't cater for different sets of users. Example:
Back when I was at school, they had a Novell network (ver 3.11)
There were the following role (actually more, but this is enough for the example):
Teachers (Email,Access to staff pool area, marks, wp apps etc)
Students (Email... that was about it back then)
StudentAdmin (controls student access)
Supervisor (think administrator)
Accounting (financial info)
Backups (had access to read everything)
It's probably obvious to say that Teachers and Students should not have supervisor priviledges over the other users. In security levels, this could be equated to the person right at the top with most access. However, the person who is in the supervisor role, does not want to have to be there all the time since there are quite a few other networks that he was administering. So he would delegate responsibility to other users. However different responsibilities needed to be delegated to different people so that no one person had complete control over the whole network. Thus the following roles were created:
StudentAdmin: This was the science teacher at the time. He could create * delete student users, modify their passwords, change their names etc
Accounting: Had access to sensitive information about the school. There is no way students should have access to this information. In fact even most teachers wouldn't see it.
Backups: Could read everything on the network, but could only write to the backup medium. If there was a call to restore something, I believe the supervisor was called in (from 60km away).
Students: Initally could only check email, but later could do some other things as well.
Teachers: Had their own private staff pool as well as their own private home drive (students had a shared one). Staff had no need for the student programs, and thus to keep things simple for the teachers (who mostly were not particularly computer literate) did not have access to the stuff the students had.
If should be becomming pretty apparent why security levels wouldn't work in this situation. The different people have different responsibilities. Some of the roles over lap and some work in parrallel. This just can't be feasilbly implemented with security levels.
I have a policy that members can not login without a password being set. As you can probably imagine, this is easy to test for, but it means you can use this to create dummy accounts as templates. In windows these are called template users, in Novell it's "inherit rights from". I apply it in a way that allows me to make a user inherit rights from more than one user. The structure of the table means that a user will only have one copy of a right, even if it has been granted more than once.
Asigning rights to users works well to begin with, but then imagine you have a whole heap of users. Let's say anything up from a hunder or so. Assignning rights to the users individually is going to become a pain in the neck. Using template users as I mentioned above will reduce the problem, but by itself is not going to help a lot as the company (and thus user roles) change. This is where groups (think roles) come in. Groups allow the administrator to give someone rights by simply putting a user in a group. For granting rights, this isn't going to make a lot of difference, however for removeing rights the difference is huge. If a user stops doing something (let's say accounting), they can simply be removed from the accounting group and all the rights that are associated with that group will be removed. However if there is a right that was in that group, but was also in another group that user is in... the removal of the first group will not interfer with any other groups, meaning that they will still have that right.
Example: Staff member is also a student. They finish and pass all classes and are now just a teacher. Both of them have email access, but the teacher no longer has need for the student programs. The user is removed from the student group removing the student programs, but the email will remain since the user is also in the teacher group.
How does this look in the db:
User: pk(UserName), Password, FirstName, LastName
UserRight: pk(UserName, RightName)
UserGroup: pk(UserName, GroupName)
GroupRight: pk(GroupName, RightName)
I've done this so all columb names that are the same line up.
A setup like this will provide the ability to use:
- Temlpate users
- Groups
- Individual Rights
- Group rights
TIP: don't hard code abilities to groups. Hard code to rights. IE:
If (HasRight("Search"))
{
// do search stuff
}
Let HasRight($RightName) do ALL the work of sussing out the groups. If can sub-contract out the work to other smaller functions if nessary, but what ever you do, DO NOT DO SOMETHING LIKE THIS:
If (HasRight("Search") or HasGroup("Teacher") or HasUser("bob234"))
{
// do search stuff
}
That would lead to disaster. Insteadlet HasRight($RightName) find were the user has the right. Assign rights to the actions and then assign those rights to group roles. And then the group roles to Users. You could even skip out the:
UserRight: pk(UserName, RightName)
and let everything happen through groups.
Using groups is a little more resource intensive than just assigning rights, but the difference it makes to administration is immense.
Things to consider:
- Who can assign what rights? I often want some people to be able to grant certain rights to other users, while a different user might be able to grant different rights to same or different users. This consept can easily be implemented by adding rights which a user may grant to a dropdown menu. this list could be considerable or really small and it would still work well.
- Who can be administered by who. This could be done by adding a table:
GroupAdmin: pk(GroupName, GroupNameAdmin)
This way groups can administer groups. Note that the GroupNameAdmin is referencing GroupName on other tables.
To sum up:
At the end of the day, creating a system like this for something really simple is probably over kill. You can always begin small with something like security levels and then if you need to assign rights later on, you could do an update query to convert users security levels to specific rights. Personally, I find right/permissions/priviledges a mich better way to work because there is so little effort to add new areas to the site. All that's needed it to create the new area, assign it a rightName and give some users that right. Security levels become a "which levels should have this access?, who has that level?, do I need a new level?..."
As I've mentioned before, Novell does this stuff really well. If you can take a look at it, it would be very benificial. I learn't on version 3.11 using a DOS client and that was very well thought out.
I need to go and do some other things now. I think the best thing from here is to look where you are unsure and I'm happy to answer questions. If there's enough interest, I might compile and organise this post, the previous one and any stuff the follows to make an article. Is there interest for that?
PS: If you really wanted, you could create a table which along the lines of:
Rights: pk(RightName), Description
This would be handy if you want to use dropdown menus to assign rights. Tables like this could be done for groups etc as well.