The AspNetWindowsAuthProvider
has this code to populate pre-difined Roles:
//Add all pre-defined Roles used to in App to 'AllRoles'
appHost.AfterInitCallbacks.Add(host =>
{
var requiredRoles = host.Metadata.OperationsMap
.SelectMany(x => x.Key.AllAttributes<RequiredRoleAttribute>()
.Concat(x.Value.ServiceType.AllAttributes<RequiredRoleAttribute>()))
.SelectMany(x => x.RequiredRoles);
requiredRoles.Each(x => AllRoles.AddIfNotExists(x));
});
But what if you’re using RequiresAnyRole
? How do those roles get populated?