Skip to content

Commit 2c78164

Browse files
committed
Merge in 'release/8.0-rc2' changes
2 parents bea85f6 + 3dbfa81 commit 2c78164

File tree

12 files changed

+9
-438
lines changed

12 files changed

+9
-438
lines changed

src/Antiforgery/src/AntiforgeryApplicationBuilderExtensions.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using Microsoft.AspNetCore.Antiforgery;
55
using Microsoft.AspNetCore.Antiforgery.Internal;
6-
using Microsoft.AspNetCore.Routing;
7-
using Microsoft.Extensions.DependencyInjection;
86

97
namespace Microsoft.AspNetCore.Builder;
108

@@ -26,19 +24,6 @@ public static IApplicationBuilder UseAntiforgery(this IApplicationBuilder builde
2624
builder.VerifyAntiforgeryServicesAreRegistered();
2725

2826
builder.Properties[AntiforgeryMiddlewareSetKey] = true;
29-
30-
// The anti-forgery middleware adds annotations to HttpContext.Items to indicate that it has run
31-
// that will be validated by the EndpointsRoutingMiddleware later. To do this, we need to ensure
32-
// that routing has run and set the endpoint feature on the HttpContext associated with the request.
33-
if (builder.Properties.TryGetValue(RerouteHelper.GlobalRouteBuilderKey, out var routeBuilder) && routeBuilder is not null)
34-
{
35-
return builder.Use(next =>
36-
{
37-
var newNext = RerouteHelper.Reroute(builder, routeBuilder, next);
38-
var antiforgery = builder.ApplicationServices.GetRequiredService<IAntiforgery>();
39-
return new AntiforgeryMiddleware(antiforgery, newNext).Invoke;
40-
});
41-
}
4227
builder.UseMiddleware<AntiforgeryMiddleware>();
4328

4429
return builder;

src/Antiforgery/src/Microsoft.AspNetCore.Antiforgery.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@
2626

2727
<ItemGroup>
2828
<Compile Include="$(SharedSourceRoot)HttpExtensions.cs" LinkBase="Shared"/>
29-
<Compile Include="$(SharedSourceRoot)Reroute.cs" LinkBase="Shared"/>
3029
</ItemGroup>
3130
</Project>

src/DefaultBuilder/src/WebApplicationBuilder.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics;
55
using System.Diagnostics.CodeAnalysis;
66
using System.Reflection;
7-
using Microsoft.AspNetCore.Antiforgery;
87
using Microsoft.AspNetCore.Authentication;
98
using Microsoft.AspNetCore.Authorization;
109
using Microsoft.AspNetCore.Hosting;
@@ -25,7 +24,6 @@ public sealed class WebApplicationBuilder : IHostApplicationBuilder
2524
private const string EndpointRouteBuilderKey = "__EndpointRouteBuilder";
2625
private const string AuthenticationMiddlewareSetKey = "__AuthenticationMiddlewareSet";
2726
private const string AuthorizationMiddlewareSetKey = "__AuthorizationMiddlewareSet";
28-
private const string AntiforgeryMiddlewareSetKey = "__AntiforgeryMiddlewareSet";
2927
private const string UseRoutingKey = "__UseRouting";
3028

3129
private readonly HostApplicationBuilder _hostApplicationBuilder;
@@ -453,15 +451,6 @@ private void ConfigureApplication(WebHostBuilderContext context, IApplicationBui
453451
}
454452
}
455453

456-
if (serviceProviderIsService?.IsService(typeof(IAntiforgery)) is true)
457-
{
458-
if (!_builtApplication.Properties.ContainsKey(AntiforgeryMiddlewareSetKey))
459-
{
460-
_builtApplication.Properties[AntiforgeryMiddlewareSetKey] = true;
461-
app.UseAntiforgery();
462-
}
463-
}
464-
465454
// Wire the source pipeline to run in the destination pipeline
466455
var wireSourcePipeline = new WireSourcePipeline(_builtApplication);
467456
app.Use(wireSourcePipeline.CreateMiddleware);

0 commit comments

Comments
 (0)