File tree Expand file tree Collapse file tree
src/BenchmarksApps/Antiforgery Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Microsoft . AspNetCore . Antiforgery ;
2+ using Microsoft . AspNetCore . Mvc ;
23using Microsoft . Extensions . Logging ;
34
45var builder = WebApplication . CreateBuilder ( args ) ;
5960app . 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.
Original file line number Diff line number Diff line change 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
77wrk .method = " POST"
8+ wrk .headers [" Content-Type" ] = " application/x-www-form-urlencoded"
9+ wrk .body = " name=benchmark"
You can’t perform that action at this time.
0 commit comments