-
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
AuthorizeAttributeAclModule fails to take into account request method #230
Comments
The httpMethod can be overridden in RequestContext, which is used to cover this scenario. There is an httpMethod property that can be set on the SiteMap node where you can specify the HTTP method to use. It defaults to "*", or any. For your scenario, you just need to set it to "POST". Keep in mind you will probably need to make another node to cover the "GET" scenario. If you find that it is not working the way you expect, feel free to open this issue again. Thanks. |
I took a look at the code, and the default value is being set to empty string instead of "*". Furthermore it not possible to set this value from Dynamic Nodes. |
…odes. Also added HttpMethod property to DynamicNode so HttpMethod can be set.
By the way, what method are you using to register your nodes? |
I have XML sitemap file for that, so no dynamic nodes. I use it for simple menu. I noticed some other weird behavior also - like sometimes acl shows an item, sometimes not and some area related stuff also, but I have not been able to pinpoint the problem and maybe it's just my code. |
For areas, you need to follow the MVC conventions outlined here: http://msdn.microsoft.com/en-us/library/ee671793(v=vs.100).aspx. In addition, you must specify namespaces on each of your routes. BTW - I have confirmed GET/POST is no longer functioning as it was intended using the demo project in #14. For some reason I have not yet determined, it is not creating a controller context for the About node. |
My bad - the GET/POST behavior is working as it was originally intended. If you add httpMethod="GET" to your node, it will use the AuthorizeAttribute from the GET action method. However, I don't think the default behavior makes sense given that the default HTML helper templates never do anything but GET. So, it seems the behavior of this feature should be changed:
That would cover all of the possible scenarios, but using httpMethod parameter would only be required if you modify the HTML helpers in some unusual way that makes them do a POST or other HTTP method. Thoughts? |
Changing default httpMethod to GET seems a good idea. |
Okay, the fix is now in v4.4.0, which is also available on NuGet. |
When I have multiple actions with the same name but one of them decorated with
[HttpPost]
attribute, then it finds wrongActionDescriptor
.I assume links in sitemap are always meant for GET?
Fortunately it was quite an easy fix, I just needed to overwrite
CreateControllerContext
method in acl module.The text was updated successfully, but these errors were encountered: