Is it possible to add custom validation to each request when authenticating web api calls using a bearer token?
I\'m using the following configuration and the applicatio
The best way I would say is to write custom attribute. You need to inherit AuthorizeAttribute
class and overridde AuthorizeCore
method, there you can add custom validation.
Once you are done, just decorate your controller or method with it.
https://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute(v=vs.118).aspx
Implementation example:
public class MyCustomAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
// your validation here
}
}
Usage examle:
[MyCustom]
public ActionResult MyAction()
{
return View();
}