Skip to content

Commit 8284a6b

Browse files
danroth27guardrex
andauthored
Update CSRF protection details in aspnetcore.md (#10489)
* Update CSRF protection details in aspnetcore.md Clarified the automatic CSRF protection feature in apps built with WebApplication.CreateBuilder, including details on its configuration and usage. * Update release-notes/11.0/preview/preview6/aspnetcore.md Co-authored-by: Luke Latham <1622880+guardrex@users.noreply.github.com> --------- Co-authored-by: Luke Latham <1622880+guardrex@users.noreply.github.com>
1 parent 7fbf1b4 commit 8284a6b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

release-notes/11.0/preview/preview6/aspnetcore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Validators run concurrently where possible: asynchronous attributes on the same
9898

9999
## Automatic cross-origin (CSRF) protection
100100

101-
Apps built with `WebApplication.CreateBuilder` now automatically reject unsafe cross-origin requests based on the browser's `Sec-Fetch-Site` and `Origin` headers ([dotnet/aspnetcore #66585](https://github.com/dotnet/aspnetcore/pull/66585), [dotnet/aspnetcore #67082](https://github.com/dotnet/aspnetcore/pull/67082)). This lightweight cross-site request forgery (CSRF) protection is on with no configuration and applies across Minimal APIs, MVC, Razor Pages, and Blazor. Same-origin requests, user-initiated navigations, and non-browser clients are allowed, while a cross-origin browser request that tries to consume a form is rejected. It can be used in place of or alongside the existing token-based antiforgery system. Because it runs automatically, the Blazor Web App project templates no longer call `app.UseAntiforgery()`.
101+
Apps built with `WebApplication.CreateBuilder` now automatically reject unsafe cross-origin requests based on the browser's `Sec-Fetch-Site` and `Origin` headers ([dotnet/aspnetcore #66585](https://github.com/dotnet/aspnetcore/pull/66585), [dotnet/aspnetcore #67082](https://github.com/dotnet/aspnetcore/pull/67082)). This lightweight cross-site request forgery (CSRF) protection is on with no configuration and applies across Minimal APIs, MVC, Razor Pages, and Blazor. Same-origin requests, user-initiated navigations, and non-browser clients are allowed, while a cross-origin browser request that tries to consume a form is rejected. It can be used in place of or alongside the existing token-based antiforgery system. Because it runs automatically, Blazor Web App projects are no longer required to call `app.UseAntiforgery()`.
102102

103103
To opt an endpoint out, use `.DisableAntiforgery()` (Minimal APIs) or `[IgnoreAntiforgeryToken]` (MVC); to turn the feature off app-wide, set the `DisableCsrfProtection` configuration key. For full control over the trust decision, register a custom `ICsrfProtection` implementation.
104104

0 commit comments

Comments
 (0)