tududi/backend/modules
Chris 6c9902b584
fix: add CSRF token support to frontend requests (#1025)
This commit implements CSRF token support for all session-based API
requests to fix the "CSRF token missing" and "CSRF token mismatch" errors
introduced after CSRF protection was added in commit 62c4cc84.

Changes:
- Created csrfService.ts utility for fetching and caching CSRF tokens
- Added getPostHeadersWithCsrf() helper to authUtils for async token injection
- Updated all service files (*Service.ts) to include CSRF tokens in POST/PUT/PATCH/DELETE requests
- Updated components with inline fetch calls to use getCsrfToken()
- Fixed CSRF middleware to use single lusca instance instead of creating new instances per request
- Improved generateToken() to use req.csrfToken() when available
- Added CalDAV path exemption to CSRF protection

Technical details:
- CSRF tokens are fetched from /api/csrf-token endpoint
- Tokens are cached and reused across requests to avoid unnecessary fetches
- Tokens are included in x-csrf-token header for state-changing requests
- Public endpoints (login, register) remain exempt from CSRF protection
- Bearer token authentication remains exempt from CSRF protection

Files modified:
- Backend: app.js, middleware/csrf.js
- Frontend: 13 service files, 8 component files
- New file: frontend/utils/csrfService.ts

This ensures all session-based requests properly include CSRF tokens while
maintaining support for API token authentication.
2026-04-14 15:06:56 +03:00
..
admin Fix admin password update silently failing due to Sequelize VIRTUAL field (#893) 2026-03-03 15:44:41 +02:00
areas Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
auth fix: add CSRF token support to frontend requests (#1025) 2026-04-14 15:06:56 +03:00
backup Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
feature-flags feat: Add MCP Integration with client-agnostic instructions (#953) 2026-03-20 16:55:49 +02:00
habits Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
inbox feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
mcp fix: use correct InboxItem model name in MCP inbox tools (#986) 2026-04-12 09:10:42 +03:00
notes Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
notifications Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
oidc fix: resolve OIDC session loss and migration failures (#1023) 2026-04-14 07:53:55 +03:00
projects Fix project update API to support clearing nullable fields (#961) 2026-03-22 22:17:23 +02:00
quotes Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
search Show original task names for recurring tasks in search results (#914) (#915) 2026-03-06 08:57:10 +02:00
shares Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
tags Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
tasks feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
telegram fix: prevent Telegram polling errors from blocking container startup (#989) (#1019) 2026-04-13 20:44:27 +03:00
url feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
users feat: Add OIDC/SSO authentication support (#1008) 2026-04-13 12:17:35 +03:00
views Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00