Closed GoogleCodeExporter closed 9 years ago
This issue was closed by revision fd6e9da7b0e9.
Original comment by alex.meyergleaves
on 30 Oct 2013 at 2:45
I see what you are trying to achieve with the attributes.
The BypassApiKeyFilterAttribute is not an actual attribute so the reflection
based GetCustomAttributes implementation will not find it. In the current Web
API integration even if you did update the filter to derive from
ActionFilterAttribute, unless you applied it to the action method as an
attribute Web API would not find it.
I have added a fluent API to the ContainerBuilder for overriding filters at the
controller or action level. The API works the same way you register filters.
Under the hood it uses the new IOverrideFilter support.
In your ShortUrl project it would like this:
builder.Register(x => new ApiAuthorizationFilterAttribute())
.AsWebApiAuthorizationFilterFor<UrlController>()
.InstancePerApiRequest();
builder.OverrideAuthorizationFilterFor<UrlController>(x =>
x.Get(default(string)));
builder.OverrideAuthorizationFilterFor<UrlController>(x =>
x.Get(default(string), default(bool)));
With this in place there is no need for your BypassApiKeyFilterAttribute. The
ApiAuthorizationFilterAttribute will simply not be called for the matching
actions (or controller if you like).
This is currently only available on the MyGet CI feed.
https://www.myget.org/feed/autofac/package/Autofac.WebApi2
I am going to add the same thing to the MVC integration and will then push both
packages to NuGet.org. If you could grab the package from MyGet and give it a
test that would be appreciated.
Original comment by alex.meyergleaves
on 30 Oct 2013 at 3:03
This works like a charm!
>>>
The BypassApiKeyFilterAttribute is not an actual attribute so the reflection
based GetCustomAttributes implementation will not find it. In the current Web
API integration even if you did update the filter to derive from
ActionFilterAttribute, unless you applied it to the action method as an
attribute Web API would not find it.
<<<
Yes, zonk... I read it over and over again. It's mentioned in the
documentation, but I just didn't got it. Was a bit late yesterday :)
Thank you for the fast patch!
Original comment by Rauber.M...@gmail.com
on 30 Oct 2013 at 3:24
Original issue reported on code.google.com by
Rauber.M...@gmail.com
on 30 Oct 2013 at 7:48