I am creating an ASP.NET Core 6 MVC app.
After the user login I go to the database and return the roles that are available for objects (textbox, buttons) for the entire application.
With those Object-Roles I want to create an authorization policy that will be used by the User to have or NOT Have access to that object.
As far as I know and my experience, the policy is set in program.cs.
services.AddAuthorization(options =>
{
options.AddPolicy("AdminAccess", policy => policy.RequireRole("Admin"));
}
But in this case, I have to do it dynamically somewhere else, after program.cs is loaded.
What is the best approach to generate these policies?
Thanks