My friend Fredrik Normen is at it again. Permission Manager continues to improve. Perhaps we should take it even further?
The latest enhancements give us the ability to specify permissions in the config file as well as other provider defined locations.
What does everyone think about putting this kind of configuration in an PermissionManager.config file or something like that as an option? I imagine the web.config might like this:
<permissionManager enabled="true" path="PermissionManager.config" />
As you can see all the remaining details might be found in an external config. It seems with all the provider stuff the web.config is growing to be a very large file. Of course we would want to still be able to use the Configuration API's as much as possible.
Thoughts on configuration and web.config usage?
For Permission Manager what about defining permissions in a custom attribute class and then having a reflection provider that harvests them from the assemblies during initialization. My thinking is that we have a synchronization issue between the permissions defined in application and those defined in the provider store. By using attributes and reflection the definitions in the code would always be in sync. It would not be necessary to define the permissions in any external location.
Today we might define a Permission to secure a method like this:
public void foo () {
// Check Permission
if (!(PermissionManager.HasPermission(“Group“, "Permission", user))) {return false};
// Permission granted
// do stuff
}
For this to work we also must make sure that the “Group“ and “Permission“ exist in the permission definition store. This requires us to create the definition prior to executing a .HasPermission().
With attributes we could perhaps do this instead:
// Check Permission automatically for current user? and define permission declaratively
[Permission(Group="Name", Permission="Name", Description="Description")]
public void foo () {
// do stuff
}
Now with reflection we can harvest the necessary permission definitions right out of the assembly. Any assembly that has a dependency on Permission Manager self describes the permissions it uses and checks attributes. I still need to understand the details and possibilities around this, but it seems there must be a way to use attributes to define the permission and secure fields, methods, and classes. The Conditional(”DEBUG”) attribute seems similar in concept. Permission Manager defines a condition based on runtime security instead of compile time. Those who have worked with attributes more please comment as to the feasibility here for both definition of permissions and runtime authorization checks.