This is not possible to just ADD new filters to the built-in AuthorizeAttribute
. You will need to create a new attribute that inherits from AuthorizeAttribute
.
There a ton of blog posts and questions on SO about creating custom AuthorizeAttributes
.
EDIT:
Ok, good start. Your issue is that you can't do Level > 1
like you are trying. Assuming you are try to say that you what auth to pass when the users Level
is greater than 1, you can change your property in the attribute to indicate this.
E.g.
public class Auth : AuthorizeAttribute
{
public int MinLevel { get; set; }
public override void OnAuthorization(AuthorizationContext filterContext)
{
//This is where you will need to determine if the user is authorized based upon the minimum level.
base.OnAuthorization(filterContext);
}
}