In order to authorize a controller for a particular role, following attribute is required on the controller class:
[Authorize(Roles = "SampleRole")]
This requires role name to be hard-coded on the Controller and does not seem to be a flexible solution. My question is that, it is possible to specify value for that role in the web.config and using that key in the controller?
<appSettings>
<add key="SampleRoleKey" value="SampleRole" />
...
</appSettings>
And in the controller,
[Authorize(Roles = "SampleRoleKey")]
Another question is that, can we use strongly typed role to authorize the controller?