- Issue: Django SECRET_KEY and database credentials were hardcoded in
settings.py - Fix: Moved all sensitive data to environment variables
- Files Modified:
Backend/backend/settings.pyBackend/env.exampleFL Model/flask/app.py
- Issue:
CORS_ALLOW_ALL_ORIGINS = Trueallowed any domain to make requests - Fix: Made CORS configurable via environment variables with secure defaults
- Issue:
DEBUG = Truein production settings - Fix: Made debug mode configurable via environment variables
# Django Settings
DJANGO_SECRET_KEY=your-secure-secret-key
DEBUG=False
ALLOWED_HOSTS=your-domain.com,www.your-domain.com
# Database Settings
DB_NAME=DiseasePrediction
DB_USER=postgres
DB_PASSWORD=your-secure-password
DB_HOST=localhost
DB_PORT=5432
# CORS Settings
CORS_ALLOW_ALL_ORIGINS=False
CORS_ALLOWED_ORIGINS=http://localhost:3000,https://your-domain.com
# Email Settings
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
# API Keys
GEMINI_API_KEY=your-gemini-api-key
# Flask App (FL Model)
FLASK_DEBUG=False- β
Never commit
.envfiles to version control - β Use strong, unique passwords for each environment
- β Rotate secrets regularly
- β Use strong database passwords
- β Limit database user permissions
- β Enable SSL connections in production
- β Regular database backups
- β Only allow necessary origins
- β Use HTTPS in production
- β
Avoid
CORS_ALLOW_ALL_ORIGINS=Truein production
- β
Set
DEBUG=Falsein production - β
Configure
ALLOWED_HOSTSproperly - β Use HTTPS and secure cookies
- β Enable CSRF protection
- β Use JWT tokens with appropriate expiration
- β Implement rate limiting
- β Validate all input data
- β Use HTTPS for all API calls
Before deploying to production:
- Generate new Django SECRET_KEY
- Set
DEBUG=False - Configure
ALLOWED_HOSTS - Set secure database credentials
- Configure CORS properly
- Enable HTTPS
- Set up proper logging
- Configure backup strategy
- Set up monitoring and alerting
- Review and update dependencies
- Input Validation: Implement comprehensive input validation
- Rate Limiting: Add rate limiting to prevent abuse
- Logging: Implement security event logging
- Monitoring: Set up intrusion detection
- Backup: Regular automated backups
- Updates: Keep all dependencies updated
- SSL/TLS: Use HTTPS everywhere
- Headers: Configure security headers (HSTS, CSP, etc.)
For security issues, please contact the development team immediately.