I'm rewriting our software for .Net 2.0 and in the process cleaning up some bad practices.
Our previous framework was based on a user object and associated permissions collection stored in a database. The user object has been converted to a singleton instead of being referenced class-to-class-to-class... but my permissions still seem to be a bit code heavy.
For example, every form has a method called from the OnLoad event which determines the buttons, menus, textboxes, etc... which are visible to the user based on their permission collection.
Example:
As you can believe, creating new permissions and adding them to already created users whenever there is a new feature request is very time consuming. I need to add the permission to the database, then assign it to the relevant people and/or roles, and finally include it within the class/form itself.
Is there a creative way I could say write a new method or add a new control and perhaps specify an attribute which will allow visibility or allow code execution based on user permission? or perhaps should I write a custom control class to handle the lookups?
I'm really smashing my brain around on this one. I'm not a security guru so there might be something to make this easier, but for the most part it has been pretty much a bunch of if...then statements which I never like to see.
I'd really like to make it part of a 'tier' as everbody is advocating. However, I cannot seem to acheive this on my own.
Our previous framework was based on a user object and associated permissions collection stored in a database. The user object has been converted to a singleton instead of being referenced class-to-class-to-class... but my permissions still seem to be a bit code heavy.
For example, every form has a method called from the OnLoad event which determines the buttons, menus, textboxes, etc... which are visible to the user based on their permission collection.
Example:
Code:
if (user.HasPermission("EditStuff"))
button1.Visible = true;
As you can believe, creating new permissions and adding them to already created users whenever there is a new feature request is very time consuming. I need to add the permission to the database, then assign it to the relevant people and/or roles, and finally include it within the class/form itself.
Is there a creative way I could say write a new method or add a new control and perhaps specify an attribute which will allow visibility or allow code execution based on user permission? or perhaps should I write a custom control class to handle the lookups?
I'm really smashing my brain around on this one. I'm not a security guru so there might be something to make this easier, but for the most part it has been pretty much a bunch of if...then statements which I never like to see.
I'd really like to make it part of a 'tier' as everbody is advocating. However, I cannot seem to acheive this on my own.