feat(api): add logging for CSRF addition (#59062)

This commit is contained in:
Sem Bauke
2025-03-03 14:42:38 +01:00
committed by GitHub
parent d56d3d15bb
commit 17838276b8
+2
View File
@@ -27,9 +27,11 @@ const csrf: FastifyPluginCallback = (fastify, _options, done) => {
// All routes except signout should add a CSRF token to the response
fastify.addHook('onRequest', (_req, reply, done) => {
const logger = fastify.log.child({ _req });
const isSignout = _req.url === '/signout' || _req.url === '/signout/';
if (!isSignout) {
logger.debug('Adding CSRF token to response');
const token = reply.generateCsrf();
void reply.setCookie(CSRF_COOKIE, token, {
sameSite: 'strict',