How can one map the role name in Authorize attribute
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 UserAccessControll开发者_如何学Goer : Controller
So that I can switch between test and production AD roles, or should i just create a custom Authorize attribute?
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.
精彩评论