Reputation: 69
I could use a good idea to "map" the role string in the [Authorize] attribute:
Have:
[Authorize(Roles = "SecAdmin")]
public class UserAccessController : Controller
Would like something like:
[Authorize(Roles = ConfigurationManager.AppSettings["SecAdminRole"] )]
public class UserAccessController : Controller
So that I can switch between test and production AD roles, or should i just create a custom Authorize attribute?
Upvotes: 1
Views: 293
Reputation: 8667
The custom Authorize attribute seems the best deal here.
You could also put the test/production separation somewhere else in your project. For example, write a custom role provider for test mode, which will grant the test admins the 'Admin' role.
Upvotes: 1