Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created May 24, 2022
Embed
What would you like to do?
[Route("api/[controller]")]
public class SecurityController : Controller
{
private readonly IAntiforgery _antiforgery;
public SecurityController(IAntiforgery antiforgery)
{
_antiforgery = antiforgery;
}
[HttpGet]
public IActionResult Get()
{
var tokens = _antiforgery.GetAndStoreTokens(HttpContext);
return new ObjectResult(new {
token = tokens.RequestToken,
tokenName = tokens.HeaderName
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment