-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self-hosted WebApi Custom Authorization Filter/Attribute using IAutofacAuthorizationFilter #66
Comments
While I don't see anything obvious, I'm on my mobile at the moment and am not doing heavy research. Since I mostly dev on Mac nowadays, it will take a while to be able to set something up to troubleshoot. This is sort of why the "new issue" page directs "how do I?" questions to Stack Overflow - there are folks doing this stuff all the time that can quickly answer the questions, and the Autofac team monitors there. For issues, only the Autofac team (of, like, three total people) watch, and it means answers may be slow. I might recommend:
Anyway, these are the steps I'd have to go through to figure it out. Sadly, I just can't keep every detail of every integration in my head anymore so I don't have these answers at my fingertips. Again, that's why we rely on Stack Overflow - to get more eyes from the community on questions, so we can focus on reproducible issues in the repos. If you figure it out, post back here so we can close the issue. If you don't... It may take a bit before I can personally come in and figure this out. |
I've taken a quick peek at the code; nothing obvious jumps out at me either. I'd consider:
|
Thanks @tillig and @alistairjevans . Let me work on your suggestions, and I will report back my findings The first thing I'm going to try is setting up a simple action filter and see if I can get that to work. I'll keep this thread posted. Thanks! |
Ok... well.. I feel like an idiot. I was working in some new code, not realizing the StartUp.cs was not being used to set up the OWIN environment. Very similar code was being wired up elsewhere in the application, so the OWIN behavior looked very similar. Once I wired up the Startup.cs I built, AutoFac started to work as designed. Sorry for the false alarm. B |
Hello,
I've read the Autofac Filter DI documentation several times. There is something I'm missing or not understanding.
I've created a authorization filter :
I wired it up in my Startup.cs like this:
I presumed the above would call my Custom filter every time the method was called in my controller. It did not. It ignored my filter.
I tried adding
[Authorize]
toMyMethod
, but that would result in an immediate 401, and never step into my filter.I tried adding
[CustomAuthorize]
toMyMethod
, that would trigger my filter, but I can't have constructor with parameters using the .NET attribute classes. This pushes me towards using the service locator inside ofCustomAuthorize
attribute instead of the runtime injection.So I have 2 question:
IAutofacAuthorizationFilter
be useful, if the above is not possible. What would trigger it?Thanks!
Brian
.NET Framework 4.8
Autofac 6.2.0
Autofac OWIN 6.0.1
Autofac.WebApi2 6.0.0
Autofac.WebApi2.Owin 6.0.0
The text was updated successfully, but these errors were encountered: