When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
Hi @nSubramanya728691 (Community Member) ,
Please note that AngularJS support ended last year. There are commercial providers that will maintain AngularJS for you but you are strongly encouraged to migrate away from AngularJS to a different JavaScript framework, for example Angular v16.
Fortunately, Angular and AngularJS use the same "X-XSRF-TOKEN" header protection:
AngularJS: https://docs.angularjs.org/api/ng/service/$http#cross-site-request-forgery-xsrf-protection
Angular: https://angular.io/guide/http-security-xsrf-protection
You should be able to use this with [ValidateAntiForgeryToken] with the following recommendation from Microsoft:
Assuming the script sends the token in a request header called X-XSRF-TOKEN, configure the antiforgery service to look for the X-XSRF-TOKEN header:
builder.Services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
The following example adds a protected endpoint that will write the request token to a JavaScript-readable cookie:
app.UseAuthorization();
app.MapGet("antiforgery/token", (IAntiforgery forgeryService, HttpContext context) =>
{
var tokens = forgeryService.GetAndStoreTokens(context);
context.Response.Cookies.Append("XSRF-TOKEN", tokens.RequestToken!,
new CookieOptions { HttpOnly = false });
return Results.Ok();
}).RequireAuthorization();
From: https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-6.0
Please let me know if you have any remaining questions or concerns.
Thank you,
Boy Baukema