I have solved it in the following way:
AuthorizeRoleAttribute.cs
public class AuthorizeRoleAttribute : AuthorizeAttribute { public AuthorizeRoleAttribute(string role) : base() { var result = Enum.Parse(typeof(RolesEnum), role); int code = result.GetHashCode(); List<string> list = new List<string>(); foreach (var item in Enum.GetValues(typeof(RolesEnum))) { int tmpCode = item.GetHashCode(); if (tmpCode >= code) { list.Add(item.ToString()); } } Roles = string.Join(",", list); } }
Role ENUM:
public enum RolesEnum { User = 100, Supervisor = 200, Administration = 300, Admin = 400 }
Controller:
[AuthorizationRole("Supervisor)] //Some Code
The controller will automaticaly look up what roles have more or equal access to supervisor by the number in the Enum.