I am decorating my controller actions with an AuthorizeAttribute.
[ServiceAuthorize(Roles="Editor,Publisher,Administrator")]
public JsonResult Create(NewsArticle newsArticle)
There is a field in my NewsArticle model that I would like to use in the OnAuthorize method in my AuthorizeAttribute.
Is there any way to get at the model from within the OnAuthorize method of the AuthorizeAttribute?
I assumed it would be available within the AuthorizationContext somewhere but I can’t find it. I know I can get to it in the ActionExecutingContext of a filter attribute but that means I would need another filter on my action and I would like to be able to perform all the authorization in a single step.
Thanks.
No because the OnAuthorization runs before the model binder. What you could do is to read the value from the value provider: