diff --git a/src/FubuMVC.AntiForgery.Docs/pak-WebContent.zip b/src/FubuMVC.AntiForgery.Docs/pak-WebContent.zip index e90fd72..9ab6f4c 100644 Binary files a/src/FubuMVC.AntiForgery.Docs/pak-WebContent.zip and b/src/FubuMVC.AntiForgery.Docs/pak-WebContent.zip differ diff --git a/src/FubuMVC.AntiForgery.Testing/Default_policy_applies_anti_forgery_to_post_routes.cs b/src/FubuMVC.AntiForgery.Testing/Default_policy_applies_anti_forgery_to_post_routes.cs new file mode 100644 index 0000000..e3cbc06 --- /dev/null +++ b/src/FubuMVC.AntiForgery.Testing/Default_policy_applies_anti_forgery_to_post_routes.cs @@ -0,0 +1,61 @@ +using System.Linq; +using FubuMVC.Core; +using FubuMVC.Core.Registration; +using FubuMVC.StructureMap; +using FubuTestingSupport; +using HtmlTags; +using NUnit.Framework; +using StructureMap; + +namespace FubuMVC.AntiForgery.Testing +{ + [TestFixture] + public class Default_policy_applies_anti_forgery_to_post_routes + { + [Test] + public void the_order_of_the_configuration_action_was_wrong() + { + var registry = new FubuRegistry(); + registry.Actions.IncludeType(); + using (var runtime = FubuApplication.For(registry).ContainerFacility(new StructureMapContainerFacility(new Container())).Bootstrap()) + { + var graph = runtime.Factory.Get(); + + graph.BehaviorFor(x => x.post_csrf(null)) + .OfType().Any() + .ShouldBeTrue(); + } + + + } + } + + public class TestEndpoint + { + public HtmlTag post_csrf(PostRequest request) + { + return new HtmlTag("h1", h => h.Text("POST HOLA")); + } + + public HtmlTag get_csrf(GetRequest request) + { + return new HtmlTag("h1", h => h.Text("GET HOLA")); + } + } + + public class GetResult + { + } + + public class GetRequest + { + } + + public class PostRequest + { + } + + public class PostResult + { + } +} \ No newline at end of file diff --git a/src/FubuMVC.AntiForgery.Testing/FubuMVC.AntiForgery.Testing.csproj b/src/FubuMVC.AntiForgery.Testing/FubuMVC.AntiForgery.Testing.csproj index 1e448a3..9d5cbb3 100644 --- a/src/FubuMVC.AntiForgery.Testing/FubuMVC.AntiForgery.Testing.csproj +++ b/src/FubuMVC.AntiForgery.Testing/FubuMVC.AntiForgery.Testing.csproj @@ -49,6 +49,9 @@ ..\packages\FubuMVC.Core.View\lib\net40\FubuMVC.Core.View.dll + + ..\packages\FubuMVC.StructureMap\lib\net40\FubuMVC.StructureMap.dll + ..\packages\FubuTestingSupport\lib\FubuTestingSupport.dll @@ -92,6 +95,7 @@ + diff --git a/src/FubuMVC.AntiForgery/AntiForgeryExtensions.cs b/src/FubuMVC.AntiForgery/AntiForgeryExtensions.cs index 6440bd5..d27feef 100644 --- a/src/FubuMVC.AntiForgery/AntiForgeryExtensions.cs +++ b/src/FubuMVC.AntiForgery/AntiForgeryExtensions.cs @@ -9,6 +9,7 @@ public void Configure(FubuRegistry registry) { registry.Services(); registry.Import(x => x.Forms.Add(new AntiForgeryTagModifier())); + registry.Policies.Add(); } } } \ No newline at end of file diff --git a/src/FubuMVC.AntiForgery/AntiForgeryPolicy.cs b/src/FubuMVC.AntiForgery/AntiForgeryPolicy.cs index 83b38bc..52bc141 100644 --- a/src/FubuMVC.AntiForgery/AntiForgeryPolicy.cs +++ b/src/FubuMVC.AntiForgery/AntiForgeryPolicy.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; -using System.Linq; +using System.Linq; +using FubuMVC.Core; using FubuMVC.Core.Registration; namespace FubuMVC.AntiForgery { + [ConfigurationType(ConfigurationType.InjectNodes)] public class AntiForgeryPolicy : IConfigurationAction { public void Configure(BehaviorGraph graph)