#17894 Making sure the AntiForgeryAuthorizationFilter makes a good attempt at getting the name ("area" value) of the currently executing module

work item: 17894

--HG--
branch : 1.x
This commit is contained in:
Nathan Heskew
2011-06-01 15:28:15 -07:00
parent 172e53dbde
commit 86c2f66488

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Environment.Extensions;
using Orchard.Mvc.Filters;
@@ -40,7 +41,7 @@ namespace Orchard.Mvc.AntiForgery {
}
private bool IsAntiForgeryProtectionEnabled(ControllerContext context) {
string currentModule = context.RouteData.Values["area"].ToString();
string currentModule = GetArea(context.RouteData);
if (!String.IsNullOrEmpty(currentModule)) {
foreach (var descriptor in _extensionManager.AvailableExtensions()) {
if (String.Equals(descriptor.Id, currentModule, StringComparison.OrdinalIgnoreCase)) {
@@ -55,6 +56,13 @@ namespace Orchard.Mvc.AntiForgery {
return false;
}
private static string GetArea(RouteData routeData) {
if (routeData.Values.ContainsKey("area"))
return routeData.Values["area"] as string;
return routeData.DataTokens["area"] as string ?? "";
}
private static bool ShouldValidateGet(AuthorizationContext context) {
const string tokenFieldName = "__RequestVerificationToken";