I want implement my own roles handling in controllers in .NET Core WEB API application. How to do this for the controller would want to support my own roles like in Identity. I don't know how to implement this to use my roles like this in original Identity.
I have 3 tables for the AppUsers:
public class AppUser
{
public int Id { get; set; }
public string Username { get; set; }
public byte[] PasswordHash { get; set; }
public byte[] PasswordSalt { get; set; }
public virtual AppUserAddress Address { get; set; }
public virtual AppUserRole Role { get; set; }
}
public class AppUserRole
{
public int Id { get; set; }
public string Name { get; set; }
}
And I want to use this roles Like this:
[HttpGet]
[Authorize(Roles = "Admin")]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}