Replace CSRF source from cookie to header in the console requests (#3047)

* Update XSRF cookie to be a header

* Replace CSRF cookie with header
This commit is contained in:
Pavlo Tkach
2026-05-15 17:45:33 +00:00
committed by GitHub
parent 0998d5485c
commit d30cc202d2
4 changed files with 19 additions and 20 deletions
@@ -38,14 +38,11 @@ public final class ConsoleApiParamsUtils {
new SendEmailUtils(ImmutableList.of("notification@test.example"), gmailClient);
XsrfTokenManager xsrfTokenManager =
new XsrfTokenManager(new FakeClock(Instant.parse("2020-02-02T01:23:45Z")));
String token =
xsrfTokenManager.generateToken(authResult.user().map(User::getEmailAddress).orElse(""));
when(request.getCookies())
.thenReturn(
new Cookie[] {
new Cookie(
XsrfTokenManager.X_CSRF_TOKEN,
xsrfTokenManager.generateToken(
authResult.user().map(User::getEmailAddress).orElse("")))
});
.thenReturn(new Cookie[] {new Cookie(XsrfTokenManager.X_CSRF_TOKEN, token)});
when(request.getHeader(XsrfTokenManager.X_CSRF_TOKEN)).thenReturn(token);
when(request.getRequestURI()).thenReturn("/console/fake-url");
return ConsoleApiParams.create(
request,