I mixed answers and proposed this method.
Firstly, We create an enum for role accesses.
public enum ERoleAccess
{
[Description("Admin User")]
Admin = 1,
[Description("General User")]
User = 2,
[Description("Editor User")]
Editor = 3,
}
Secondly, we need an attribute filter for customer MVC authorize.
public class RolesAttribute:AuthorizeAttribute
{
public RolesAttribute(params ERoleAccess[] roles)
{
Roles = string.Join(",", roles);
}
}
Finally, we can use "RolesAttribute" on the controllers or actions.
[Roles(ERoleAccess.Admin, ERoleAccess.Editor, ERoleAccess.User)]
In this approach, we use numbers of alternative string values.
(1= Admin, 2=User,...)
It's good for decreasing token size and comparing performance.