I am building a MVC app in asp.net core 6. The app is done but I want it to be used only by selected few users. I want these users to be stored in a file so that they can be added later by a SYSadmin. Right now I am using the following code:
{
var policy = new AuthorizationPolicyBuilder()
.RequireAssertion(x =>
x.User.Identity!.Name == "DOMAIN\\NAME" ||
x.User.Identity!.Name == "DOMAIN2\\NAME2"
)
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
I would like this to be replaced with a code which reads the allowed users from a file. Thank you.