-
Notifications
You must be signed in to change notification settings - Fork 218
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
Authorization failures #417
Comments
if (!typeof(filterContext).Namespace.StartsWith("MvcSiteMapProvider"))
{
// Do logging
} Note that if you need to pass this information to
That said, I have considered doing caching but when I tried to implement it I realized just how complicated it would be. Not to mention, breaking API changes. The controller can be created using the If we keep this redundancy in place, the way each controller was created would need to be tracked along with the instance so we would know whether to call The controller instances would need to be tracked in a thread-safe manner and released at the end of the request. To remain MVC-centric, that should probably be done using In fact, this new service should probably be responsible for either creating the controller or retrieving it from the cache so the I would not be opposed to a pull request with a prototype, but be sure to incorporate the changes from this gist from #412. Also note that those changes don't actually fix the original issue in #412, which was to use the |
The filtercontext idea will definitely help! For me, I am comfortable having the entire permissions structure of the sitemap read one time at startup...as long as there is a way to 'refresh' it... |
Since permissions are user-based, loading it at startup is not possible. The best we could do is load it into a user session. But then, that assumes we use session state, which we currently don't as session state is something I have been avoiding for scalability reasons. But still, there would be a performance gain if each action didn't have to create a new instance of the controller just to check if it is authorized. So I will consider this a feature request. |
Well, it could store it in some ICacheProvider interface that defaulted to 'nothing' so it was not cached. Then simply make the key to the cache item a function of the username (or anonymous)...etc. (Just a quick thought...) In my sitemap, I have filled out the Roles=* attribute. So, for me I really just need you to ask if the user is in that role. No need to create the controller. So, in the above example - if I create custom IAclModule that simply checks the role - will all the controllers stop being created? (or is there another easy way)? |
I have considered doing something like this before. Then I remembered that some people are on server farms and it is much better for them to use session state (which can be shared between servers) rather than using a cache (unless of course it is a distributed cache).
Actually, you don't need to jump through so many hoops. The default configuration automatically wires up an But then, if you want your controller actions to have any measure of security, you need to duplicate your roles in the |
We already use AuthorzeAttribute on the controllers...AND already have it in the sitemap...so was already doing both. I will try to disable that module and see what I get! (Could be some are out of sync too). Cache - yes, that was why it would be an ICacheProvider. They could implement that with a session, local cache, distributed cache, etc. Thanks for responses. |
I will consider some sort of caching at the user level. But even if not doing that, most would benefit significantly by request caching the controllers so each one is only created once per request instead of once per action. Either way, this is still an open issue that needs to be resolved. Perhaps this is an excuse to finally push forward version 4.7, which I have been holding off on because there are only bug fixes but no features to release and it will require breaking external DI configuration changes. |
Is not it a user level caching? |
I was attempting to log all authorization failures of [Authorize] attributes on controllers and actions.
I can log them of course. The problem is that MvcSiteMapProvider appears to go through the entire sitemap on every request and attempt to authorize every node - to do 'security trimming'.
Are there any options here?
Thoughts?
The text was updated successfully, but these errors were encountered: