Windsor IInterceptorを使用してMVCアプリで承認を処理しようとしています。これは、ユーザーがアクセス権を持っているかどうかを判断するために関連するアクションが渡されるパラメーターへの名前付きアクセスを取得できる唯一の方法のように思われるためです。
私のInterceptメソッドから、呼び出されるアクションにアクセスする必要があります。コントローラーとアクションの名前を(RequestContextを介して)取得する方法を理解しましたが、実際のメソッドは理解していません-何か良いアイデアはありますか?
参考までに、これはおおよそコードがどのように見えるかです。
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();
}
}