Created
May 24, 2022 12:31
-
-
Save lgolubyev/ac46a0fc828e2fa757cf475b1f8d50a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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