I want to add some policies to ASP.Net Core authorization, which are stored in my database (EF Core with MySQL). The goal is to limit users' access based on their authorities. As far as I know, I should do it in the ConfigureServices method in the Startup class like this:
services.AddAuthorizationCore(options =>
{
options.AddPolicy("CanEditUserGroups", builder =>
{
builder.RequireAuthenticatedUser();
builder.RequireClaim("Permission", "Value");
});
});
But, the problem is that I want to have several policies and read their "Value" from the database. Is it possible to instantiate my DbContext service and read data from that? Am I doing it the right way?