Im looking to handle authorization in an MVC app through the use of a Windsor IInterceptor - because this seems like the only way I can get named access to parameters the action is passed which are relevant for determining if the user has access.
From my Intercept method I need access to the action that is called. I figured out how to get the controller and action names (through the RequestContext), but not the actual method - any good ideas?
As a reference this is roughly how the code looks as is:
public class AuthorizationInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
if (invocation.Arguments != null && invocation.Arguments.Length > 0 && invocation.Arguments[0] != null)
{
if (invocation.Arguments[0].GetType() == typeof(RequestContext))
{
var context = (RequestContext)invocation.Arguments[0];
var values = context.RouteData.Values;
if (!auth.Authorize(values, HttpContext.Current.User))
{
//RedirectToLogin }
}
}
invocation.Proceed();
}
}