Skip to content

Commit 355cf78

Browse files
committed
try fix
1 parent 318ef47 commit 355cf78

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/BenchmarksApps/Antiforgery/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.AspNetCore.Antiforgery;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.Extensions.Logging;
34

45
var builder = WebApplication.CreateBuilder(args);
@@ -59,8 +60,7 @@
5960
app.MapGet("/", () => Results.Ok("hello world!"));
6061

6162
// POST endpoint guarded only by the auto-injected cross-origin CSRF protection.
62-
// Sec-Fetch-Site: same-origin/none => 200; cross-site/same-site => 400.
63-
app.MapPost("/csrf", () => Results.Ok());
63+
app.MapPost("/csrf", ([FromForm] string name) => Results.Ok());
6464

6565
// Token-based antiforgery endpoints. These depend on IAntiforgery, which is only
6666
// registered when the token-based antiforgery services are added above.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
-- POSTs to /csrf to exercise the auto-injected cross-origin (Sec-Fetch) CSRF protection.
2-
-- The Sec-Fetch-Site header is supplied per scenario via the wrk `customHeaders` variable
3-
-- ("same-origin" => accepted/200, "cross-site" => rejected/400). wrk delivers script `--`
4-
-- arguments only to init(args), so the header is sent through wrk's native --header instead
5-
-- to guarantee the value reliably reaches the server.
1+
-- POSTs a form to /csrf to exercise the auto-injected cross-origin (Sec-Fetch) CSRF protection.
2+
-- The endpoint binds [FromForm], so the request carries a urlencoded body; reading the form is what
3+
-- triggers the (post-#67082 lazy) CSRF verdict. The Sec-Fetch-Site header is supplied per scenario
4+
-- via the wrk `customHeaders` variable ("same-origin" => accepted/200, "cross-site" => rejected/400)
5+
-- so it reliably reaches the server through wrk's native --header.
66

77
wrk.method = "POST"
8+
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
9+
wrk.body = "name=benchmark"

0 commit comments

Comments
 (0)