mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2025-12-31 00:09:58 -06:00
This commit introduces a comprehensive Kanban board customization system and improves CSRF token configuration for Docker deployments. ## Major Features ### 1. Customizable Kanban Board Columns Add complete kanban column customization system allowing users to define custom workflow states beyond the default columns. **New Components:** - Add KanbanColumn model with full CRUD operations (app/models/kanban_column.py) - Add kanban routes blueprint with admin endpoints (app/routes/kanban.py) - Add kanban column management templates (app/templates/kanban/) - Add migration 019 for kanban_columns table (migrations/) **Features:** - Create unlimited custom columns with unique keys, labels, icons, and colors - Drag-and-drop column reordering with position persistence - Toggle column visibility without deletion - Protected system columns (todo, in_progress, done) prevent accidental deletion - Complete state marking for columns that should mark tasks as done - Real-time updates via SocketIO broadcasts when columns change - Font Awesome icon support (5000+ icons) - Bootstrap color scheme integration - Comprehensive validation and error handling **Integration:** - Update Task model to work with dynamic column statuses (app/models/task.py) - Update task routes to use kanban column API (app/routes/tasks.py) - Update project routes to fetch active columns (app/routes/projects.py) - Add kanban column management links to base template (app/templates/base.html) - Update kanban board templates to render dynamic columns (app/templates/tasks/) - Add cache prevention headers to force fresh column data **API Endpoints:** - GET /api/kanban/columns - Fetch all active columns - POST /api/kanban/columns/reorder - Reorder columns - GET /kanban/columns - Column management interface (admin only) - POST /kanban/columns/create - Create new column (admin only) - POST /kanban/columns/<id>/edit - Edit column (admin only) - POST /kanban/columns/<id>/delete - Delete column (admin only) - POST /kanban/columns/<id>/toggle - Toggle column visibility (admin only) ### 2. Enhanced CSRF Configuration Improve CSRF token configuration and documentation for Docker deployments. **Configuration Updates:** - Add WTF_CSRF_ENABLED environment variable to all docker-compose files - Add WTF_CSRF_TIME_LIMIT environment variable with 1-hour default - Update app/config.py to read CSRF settings from environment - Add SECRET_KEY validation in app/__init__.py to prevent production deployment with default keys **Docker Compose Updates:** - docker-compose.yml: CSRF enabled by default for security testing - docker-compose.remote.yml: CSRF always enabled in production - docker-compose.remote-dev.yml: CSRF enabled with production-like settings - docker-compose.local-test.yml: CSRF can be disabled for local testing - Add helpful comments explaining each CSRF-related environment variable - Update env.example with CSRF configuration examples **Verification Scripts:** - Add scripts/verify_csrf_config.sh for Unix systems - Add scripts/verify_csrf_config.bat for Windows systems - Scripts check SECRET_KEY, CSRF_ENABLED, and CSRF_TIME_LIMIT settings ### 3. Database Initialization Improvements - Update app/__init__.py to run pending migrations on startup - Add automatic kanban column initialization after migrations - Improve error handling and logging during database setup ### 4. Configuration Management - Update app/config.py with new CSRF and kanban-related settings - Add environment variable parsing with sensible defaults - Improve configuration validation and error messages ## Documentation ### New Documentation Files - CUSTOM_KANBAN_README.md: Quick start guide for kanban customization - KANBAN_CUSTOMIZATION.md: Detailed technical documentation - IMPLEMENTATION_SUMMARY.md: Implementation details and architecture - KANBAN_AUTO_REFRESH_COMPLETE.md: Real-time update system documentation - KANBAN_REFRESH_FINAL_FIX.md: Cache and refresh troubleshooting - KANBAN_REFRESH_SOLUTION.md: Technical solution for data freshness - docs/CSRF_CONFIGURATION.md: Comprehensive CSRF setup guide - CSRF_DOCKER_CONFIGURATION_SUMMARY.md: Docker-specific CSRF setup - CSRF_TROUBLESHOOTING.md: Common CSRF issues and solutions - APPLY_KANBAN_MIGRATION.md: Migration application guide - APPLY_FIXES_NOW.md: Quick fix reference - DEBUG_KANBAN_COLUMNS.md: Debugging guide - DIAGNOSIS_STEPS.md: System diagnosis procedures - BROWSER_CACHE_FIX.md: Browser cache troubleshooting - FORCE_NO_CACHE_FIX.md: Cache prevention solutions - SESSION_CLOSE_ERROR_FIX.md: Session handling fixes - QUICK_FIX.md: Quick reference for common fixes ### Updated Documentation - README.md: Add kanban customization feature description - Update project documentation with new features ## Testing ### New Test Files - test_kanban_refresh.py: Test kanban column refresh functionality ## Technical Details **Database Changes:** - New table: kanban_columns with 11 columns - Indexes on: key, position - Default data: 4 system columns (todo, in_progress, review, done) - Support for both SQLite (development) and PostgreSQL (production) **Real-Time Updates:** - SocketIO events: 'kanban_columns_updated' with action type - Automatic page refresh when columns are created/updated/deleted/reordered - Prevents stale data by expiring SQLAlchemy caches after changes **Security:** - Admin-only access to column management - CSRF protection on all column mutation endpoints - API endpoints exempt from CSRF (use JSON and other auth mechanisms) - System column protection prevents data integrity issues - Validation prevents deletion of columns with active tasks **Performance:** - Efficient querying with position-based ordering - Cached column data with cache invalidation on changes - No-cache headers on API responses to prevent stale data - Optimized database indexes for fast lookups ## Breaking Changes None. This is a fully backward-compatible addition. Existing workflows continue to work with the default columns. Custom columns are opt-in via the admin interface. ## Migration Notes 1. Run migration 019 to create kanban_columns table 2. Default columns are initialized automatically on first run 3. No data migration needed for existing tasks 4. Existing task statuses map to new column keys ## Environment Variables New environment variables (all optional with defaults): - WTF_CSRF_ENABLED: Enable/disable CSRF protection (default: true) - WTF_CSRF_TIME_LIMIT: CSRF token expiration in seconds (default: 3600) - SECRET_KEY: Required in production, must be cryptographically secure See env.example for complete configuration reference. ## Deployment Notes
78 lines
2.4 KiB
Plaintext
78 lines
2.4 KiB
Plaintext
# Flask settings
|
|
# CRITICAL: Change SECRET_KEY in production! Used for sessions, cookies, and CSRF tokens.
|
|
# Generate a secure key with: python -c "import secrets; print(secrets.token_hex(32))"
|
|
# The same key must be used across restarts and all app replicas.
|
|
SECRET_KEY=your-secret-key-here
|
|
FLASK_ENV=production
|
|
FLASK_DEBUG=false
|
|
|
|
# Database settings
|
|
DATABASE_URL=postgresql+psycopg2://timetracker:timetracker@db:5432/timetracker
|
|
POSTGRES_DB=timetracker
|
|
POSTGRES_USER=timetracker
|
|
POSTGRES_PASSWORD=timetracker
|
|
POSTGRES_HOST=db
|
|
|
|
# Session settings
|
|
SESSION_COOKIE_SECURE=false
|
|
SESSION_COOKIE_HTTPONLY=true
|
|
PERMANENT_SESSION_LIFETIME=86400
|
|
|
|
# Application settings
|
|
TZ=Europe/Rome
|
|
CURRENCY=EUR
|
|
ROUNDING_MINUTES=1
|
|
SINGLE_ACTIVE_TIMER=true
|
|
IDLE_TIMEOUT_MINUTES=30
|
|
|
|
# User management
|
|
ALLOW_SELF_REGISTER=true
|
|
ADMIN_USERNAMES=admin
|
|
|
|
# Authentication
|
|
# Options: local | oidc | both
|
|
AUTH_METHOD=local
|
|
|
|
# OIDC (used when AUTH_METHOD=oidc or both)
|
|
# OIDC_ISSUER=https://login.microsoftonline.com/<tenant>/v2.0
|
|
# OIDC_CLIENT_ID=
|
|
# OIDC_CLIENT_SECRET=
|
|
# OIDC_REDIRECT_URI=https://yourapp.example.com/auth/oidc/callback
|
|
# OIDC_SCOPES=openid profile email
|
|
# OIDC_USERNAME_CLAIM=preferred_username
|
|
# OIDC_FULL_NAME_CLAIM=name
|
|
# OIDC_EMAIL_CLAIM=email
|
|
# OIDC_GROUPS_CLAIM=groups
|
|
# OIDC_ADMIN_GROUP=
|
|
# OIDC_ADMIN_EMAILS=
|
|
# OIDC_POST_LOGOUT_REDIRECT_URI=https://yourapp.example.com/
|
|
|
|
# Backup settings
|
|
BACKUP_RETENTION_DAYS=30
|
|
BACKUP_TIME=02:00
|
|
|
|
# File upload settings
|
|
MAX_CONTENT_LENGTH=16777216
|
|
UPLOAD_FOLDER=/data/uploads
|
|
|
|
# CSRF protection
|
|
# IMPORTANT: Keep CSRF enabled in production for security
|
|
# Only disable for development/testing if needed
|
|
WTF_CSRF_ENABLED=true
|
|
WTF_CSRF_TIME_LIMIT=3600
|
|
|
|
# TROUBLESHOOTING CSRF issues ("CSRF token missing or invalid" errors):
|
|
# 1. SECRET_KEY changed? All CSRF tokens become invalid when SECRET_KEY changes
|
|
# 2. Cookies blocked? Check browser settings and allow cookies from your domain
|
|
# 3. Behind a proxy? Ensure proxy forwards cookies and doesn't strip them
|
|
# 4. Token expired? Increase WTF_CSRF_TIME_LIMIT (in seconds)
|
|
# 5. Multiple app instances? All must use the SAME SECRET_KEY
|
|
# 6. Clock skew? Ensure server time is synchronized (use NTP)
|
|
# 7. Still broken? Try: docker-compose restart app
|
|
# 8. For testing only: Set WTF_CSRF_ENABLED=false (NOT for production!)
|
|
# See docs/CSRF_CONFIGURATION.md for detailed troubleshooting
|
|
|
|
# Logging
|
|
LOG_LEVEL=INFO
|
|
LOG_FILE=/data/logs/timetracker.log
|