Complete reorganization of project documentation to improve discoverability, navigation, and maintainability. All documentation has been restructured into a clear, role-based hierarchy. ## Major Changes ### New Directory Structure - Created `docs/api/` for API documentation - Created `docs/admin/` with subdirectories: - `admin/configuration/` - Configuration guides - `admin/deployment/` - Deployment guides - `admin/security/` - Security documentation - `admin/monitoring/` - Monitoring and analytics - Created `docs/development/` for developer documentation - Created `docs/guides/` for user-facing guides - Created `docs/reports/` for analysis reports and summaries - Created `docs/changelog/` for detailed changelog entries (ready for future use) ### File Organization #### Moved from Root Directory (40+ files) - Implementation notes → `docs/implementation-notes/` - Test reports → `docs/testing/` - Analysis reports → `docs/reports/` - User guides → `docs/guides/` #### Reorganized within docs/ - API documentation → `docs/api/` - Administrator documentation → `docs/admin/` (with subdirectories) - Developer documentation → `docs/development/` - Security documentation → `docs/admin/security/` - Telemetry documentation → `docs/admin/monitoring/` ### Documentation Updates #### docs/README.md - Complete rewrite with improved navigation - Added visual documentation map - Organized by role (Users, Administrators, Developers) - Better categorization and quick links - Updated all internal links to new structure #### README.md (root) - Updated all documentation links to reflect new structure - Fixed 8 broken links #### app/templates/main/help.html - Enhanced "Where can I get additional help?" section - Added links to new documentation structure - Added documentation index link - Added admin documentation link for administrators - Improved footer with organized documentation links - Added "Complete Documentation" section with role-based links ### New Index Files - Created README.md files for all new directories: - `docs/api/README.md` - `docs/guides/README.md` - `docs/reports/README.md` - `docs/development/README.md` - `docs/admin/README.md` ### Cleanup - Removed empty `docs/security/` directory (moved to `admin/security/`) - Removed empty `docs/telemetry/` directory (moved to `admin/monitoring/`) - Root directory now only contains: README.md, CHANGELOG.md, LICENSE ## Results **Before:** - 45+ markdown files cluttering root directory - Documentation scattered across root and docs/ - Difficult to find relevant documentation - No clear organization structure **After:** - 3 files in root directory (README, CHANGELOG, LICENSE) - Clear directory structure organized by purpose and audience - Easy navigation with role-based organization - All documentation properly categorized - Improved discoverability ## Benefits 1. Better Organization - Documentation grouped by purpose and audience 2. Easier Navigation - Role-based sections (Users, Admins, Developers) 3. Improved Discoverability - Clear structure with README files in each directory 4. Cleaner Root - Only essential files at project root 5. Maintainability - Easier to add and organize new documentation ## Files Changed - 40+ files moved from root to appropriate docs/ subdirectories - 15+ files reorganized within docs/ - 3 major documentation files updated (docs/README.md, README.md, help.html) - 5 new README index files created - 2 empty directories removed All internal links have been updated to reflect the new structure.
8.5 KiB
CSRF IP Access Fix - Implementation Summary
Problem Solved
Issue: CSRF cookie (XSRF-TOKEN) is created correctly when accessing via localhost but NOT created when accessing via remote IP address (e.g., http://192.168.1.100:8080).
Root Cause: The WTF_CSRF_SSL_STRICT=true (default) setting blocks cookie creation for HTTP connections to non-localhost addresses as a security measure.
Solution Implemented
Quick Fix for Users
We've provided an automated script that configures the application correctly for IP address access:
Linux/Mac:
bash scripts/fix_csrf_ip_access.sh
Windows:
scripts\fix_csrf_ip_access.bat
The script sets:
WTF_CSRF_SSL_STRICT=false— Allows CSRF tokens over HTTPSESSION_COOKIE_SECURE=false— Allows session cookies over HTTPCSRF_COOKIE_SECURE=false— Allows CSRF cookies over HTTP
Files Modified
1. Configuration Files
env.example
- Added
WTF_CSRF_SSL_STRICT=falsesetting with documentation - Added detailed comments about CSRF cookie settings
- Added specific guidance for IP address access
- Updated troubleshooting tips
docker-compose.yml
- Added
WTF_CSRF_SSL_STRICTenvironment variable with defaultfalse - Added
SESSION_COOKIE_SECUREenvironment variable with defaultfalse - Enhanced documentation about CSRF configuration
- Added reference to new troubleshooting guides
2. Documentation Created
docs/CSRF_IP_ACCESS_GUIDE.md (NEW)
Comprehensive guide covering:
- Problem description and root cause
- Quick fix instructions
- Detailed explanation of each setting
- Testing procedures
- Security considerations
- Alternative solutions (domain names, HTTPS)
- Troubleshooting steps
- Configuration examples for different environments
CSRF_IP_ACCESS_FIX.md (NEW)
Quick reference guide with:
- Problem summary
- One-command fixes
- Verification steps
- Security notes
- Alternative solutions
- Troubleshooting checklist
CSRF_IP_FIX_SUMMARY.md (THIS FILE)
Implementation summary documenting all changes
3. Existing Documentation Updated
CSRF_TROUBLESHOOTING.md
- Added new section #8: "Accessing via IP Address (Not Localhost)"
- Updated related documentation links
- Added reference to the new IP access guide
README.md
- Added link to
CSRF_IP_ACCESS_FIX.mdin troubleshooting section - Highlighted with 🔥 emoji for visibility
4. Automation Scripts Created
scripts/fix_csrf_ip_access.sh (NEW)
Bash script for Linux/Mac that:
- Checks for
.envfile, creates if missing - Shows current CSRF configuration
- Updates
.envwith correct settings - Restarts the Docker container
- Provides verification steps
scripts/fix_csrf_ip_access.bat (NEW)
Windows batch script that:
- Uses PowerShell for
.envfile manipulation - Same functionality as bash version
- Windows-friendly output and instructions
Configuration Details
Development/Testing (HTTP, IP Access)
WTF_CSRF_SSL_STRICT=false
SESSION_COOKIE_SECURE=false
CSRF_COOKIE_SECURE=false
SESSION_COOKIE_SAMESITE=Lax
CSRF_COOKIE_SAMESITE=Lax
Production (HTTPS, Domain)
WTF_CSRF_SSL_STRICT=true
SESSION_COOKIE_SECURE=true
CSRF_COOKIE_SECURE=true
SESSION_COOKIE_SAMESITE=Strict
CSRF_COOKIE_SAMESITE=Strict
How It Works
Before the Fix
- User accesses
http://192.168.1.100:8080 - Flask-WTF checks
WTF_CSRF_SSL_STRICTsetting (default:true) - Since request is HTTP to non-localhost, Flask-WTF blocks cookie creation
- CSRF cookie is NOT set in browser
- Form submissions fail with "CSRF token missing or invalid"
After the Fix
- User accesses
http://192.168.1.100:8080 - Flask-WTF checks
WTF_CSRF_SSL_STRICTsetting (now:false) - Flask-WTF allows cookie creation over HTTP
- CSRF cookie (
XSRF-TOKEN) is set in browser - Form submissions work correctly ✅
Security Considerations
Safe For:
- ✅ Development environments
- ✅ Testing on local networks
- ✅ Private/trusted networks (VPN, home network)
- ✅ Isolated lab environments
NOT Safe For:
- ❌ Public internet without HTTPS
- ❌ Production with sensitive data over HTTP
- ❌ Untrusted networks
- ❌ Public-facing applications
Recommendations:
- Development: Use the provided settings (
WTF_CSRF_SSL_STRICT=false) - Production: Always use HTTPS with strict settings (
WTF_CSRF_SSL_STRICT=true) - Network Security: If using HTTP, ensure network is trusted
- Migration: When moving to production, update all security settings
Testing the Fix
1. Apply the Fix
bash scripts/fix_csrf_ip_access.sh # or .bat on Windows
2. Verify Environment
docker-compose exec app env | grep -E "WTF_CSRF|SESSION_COOKIE|CSRF_COOKIE"
3. Check Cookies in Browser
- Open DevTools (F12)
- Navigate to
http://YOUR_IP:8080 - Go to Application → Cookies
- Verify
sessionandXSRF-TOKENcookies exist
4. Test CSRF Endpoint
curl -v http://YOUR_IP:8080/auth/csrf-token
Look for Set-Cookie headers in response.
5. Test Form Submission
- Try logging in via IP address
- Submit any form (create project, log time, etc.)
- Should work without CSRF errors ✅
Alternative Solutions
Option 1: Use Domain Name Instead of IP
# Add to hosts file
192.168.1.100 timetracker.local
# Access via domain
http://timetracker.local:8080
Option 2: Enable HTTPS with Self-Signed Certificate
# Generate certificate
openssl req -x509 -newkey rsa:4096 -nodes \
-keyout key.pem -out cert.pem -days 365 \
-subj "/CN=192.168.1.100"
# Configure nginx/docker for HTTPS
# Set all security flags to true
Option 3: Disable CSRF (Development Only)
WTF_CSRF_ENABLED=false # ⚠️ ONLY for isolated development!
Rollback Instructions
If you need to revert to strict security settings:
- Edit
.env:
WTF_CSRF_SSL_STRICT=true
SESSION_COOKIE_SECURE=true
CSRF_COOKIE_SECURE=true
- Restart:
docker-compose restart app
Note: This will prevent IP access over HTTP again.
User Experience Impact
Before Fix:
- ❌ Users accessing via IP see CSRF errors on all forms
- ❌ Login fails with "CSRF token missing or invalid"
- ❌ No clear error message about IP/localhost difference
- ❌ Users confused why localhost works but IP doesn't
After Fix:
- ✅ Automated script makes fix one-click easy
- ✅ Clear documentation explains the issue
- ✅ Multiple solutions provided (scripts, manual, alternatives)
- ✅ Users understand security implications
- ✅ Separate configs for dev/prod clearly documented
Integration with Existing Documentation
This fix integrates with:
CSRF_TROUBLESHOOTING.md— Main troubleshooting guidedocs/CSRF_CONFIGURATION.md— Detailed CSRF configurationdocs/DOCKER_PUBLIC_SETUP.md— Docker setup guideenv.example— Configuration template
Future Improvements
Potential enhancements:
- Auto-detection of access method (localhost vs IP)
- Configuration wizard for first-time setup
- Web UI warning when accessing via IP with strict settings
- Automated HTTPS setup script with Let's Encrypt
- Environment-specific docker-compose files (dev/prod)
Summary
This fix provides:
- ✅ Immediate solution via automated scripts
- ✅ Clear documentation explaining the problem and fix
- ✅ Security guidance for different environments
- ✅ Multiple approaches (automated, manual, alternatives)
- ✅ Comprehensive testing procedures
- ✅ User-friendly implementation
Result: Users can now access the application via IP address without CSRF cookie issues, while understanding the security implications and having clear paths for both development and production configurations.
Files Changed Summary
New Files Created (7):
docs/CSRF_IP_ACCESS_GUIDE.md— Comprehensive guideCSRF_IP_ACCESS_FIX.md— Quick referencescripts/fix_csrf_ip_access.sh— Linux/Mac automationscripts/fix_csrf_ip_access.bat— Windows automationCSRF_IP_FIX_SUMMARY.md— This summary
Files Modified (4):
env.example— Added CSRF IP settingsdocker-compose.yml— Added environment variablesCSRF_TROUBLESHOOTING.md— Added IP access sectionREADME.md— Added link to fix guide
Total Impact:
- 11 files changed/created
- 5 documentation files
- 2 automation scripts
- 4 configuration files
Implementation Date: October 2024
Tested On: TimeTracker v1.0+
Issue: CSRF cookies not created when accessing via IP address
Status: ✅ Resolved