I am beginning to decorate my controller classes with
[Authorize(Roles = @"DOMAIN\ADGroup")]
What would be the best method to change that explicit string to a parameter that collects the role assignment from a database, thus allowing flexibility in role assignment that an Admin area can sit on top off.
For example say I have three roles, for arguments sake
- ReadOnly
- ReadandWrite
- Admin
And I want to map those roles to Multiple AD groups
For example
- ReadOnly --> DOMAIN\Group1, DOMAIN\Group2, DOMAIN\Group3
- ReadandWrite--> DOMAIN\GroupWrite, DOMAIN\GroupManagers
- Admin --> DOMAIN\DomainAdmins
This will be editable, I can modify the mapping from role to any AD group I choose in the Admin area of my application.
How can my Authorize attributes take advantage of this?