tududi/backend/scripts
Chris ca77222eae
fix: resolve OIDC session loss and migration failures (#1023)
* fix: resolve OIDC session loss and migration failures

This commit fixes three critical issues affecting OIDC/SSO authentication:

1. Session Not Saved Before Redirect
   - Added explicit req.session.save() callback in OIDC callback handler
   - Ensures session is persisted before redirecting to /today
   - Prevents 401 errors after successful SSO authentication

2. Migration Resilience
   - Added DROP TABLE IF EXISTS users_new in migration
   - Prevents "table already exists" errors from failed migrations
   - Created cleanup script for orphaned migration tables

3. Trust Proxy Documentation
   - Documented TUDUDI_TRUST_PROXY requirement for reverse proxy deployments
   - Added troubleshooting guide for session loss issues
   - Updated .env.example with OIDC configuration examples

Fixes session loss when deployed behind reverse proxies (nginx, Traefik, etc.)

Changes:
- backend/modules/oidc/controller.js: Add session.save() before redirect
- backend/migrations/20260420000004-make-password-optional.js: Add DROP TABLE IF EXISTS
- backend/scripts/cleanup-failed-migration.js: New cleanup utility
- backend/.env.example: Add OIDC and trust proxy examples
- docs/10-oidc-sso.md: Add trust proxy configuration and troubleshooting
- docs/feature-plans/00-oidc-sso.md: Document required environment variables

* fix: prettier formatting in cleanup script
2026-04-14 07:53:55 +03:00
..
add-sample-users.js Add translations 2025-10-15 13:05:57 +03:00
cleanup-failed-migration.js fix: resolve OIDC session loss and migration failures (#1023) 2026-04-14 07:53:55 +03:00
db-init.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
db-migrate.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
db-reset.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
db-status.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
db-sync.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
migration-create.js Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
reset-and-seed.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
seed-dev-data.js Parallelize test running (#166) 2025-07-16 13:27:57 +03:00
user-create.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00