It's definitely being called every time. For now I added a work
around that shortcircuits the login within the filter by forcing me to
define a filter with a true value on an authorize property. Here's
the code:
Injection code:
builder.RegisterType<ExtensibleActionInvoker>().As<IActionInvoker>();
builder.RegisterControllers(Assembly.GetExecutingAssembly()).InjectActionInvoker();
// values that are injected as properties on
builder.Register(c => new
NonceStore()).As<INonceStore>().InstancePerHttpRequest();
builder.Register(c => new
TokenManager()).As<IServiceProviderTokenManager>().InstancePerHttpRequest();
// now inject any action filters here.
builder.RegisterType<OAuthFilterAttribute>().As<IAuthorizationFilter>().PropertiesAutowired(PropertyWiringFlags.PreserveSetValues);
builder.RegisterFilterProvider();
Code for my filter:
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class OAuthFilterAttribute : ActionFilterAttribute,
IAuthorizationFilter
{
public IServiceProviderTokenManager TokenManager { get; set; }
public INonceStore NonceStore { get; set; }
public bool Authorize { get; set; }
public OAuthFilterAttribute()
{
Authorize = false;
}
public void OnAuthorization(AuthorizationContext
filterContext)
{
if (!Authorize)
return;
... go ahead and do stuff
}
}
On Nov 9, 10:23 am, Alex Meyer-Gleaves <
alex.meyerglea...@gmail.com>
wrote:
> Hi Alex,
>
> Your custom attribute should not be treated as a global filter by default.
> It should only be returned from the filter provider when your
> AuthorizeAttribute derived attribute is found on the action being invoked.
> Are you using the MVC 3 integration and the
> ContainerBuilder.RegisterFilterProvider method to configure filter
> attribute injection?
>
> Cheers,
>
> Alex.
>