Internal
Public Access
Security improvements: - selfhosted.py: Require SECRET_KEY environment variable (raises ValueError if not set) - selfhosted.py: Validate SECRET_KEY length (minimum 50 characters) - selfhosted.py: Warn if DEBUG=True in self-hosted mode - development.py: Auto-generate random SECRET_KEY on each startup if not provided - development.py: Remove production domain from ALLOWED_HOSTS - development.py: Make CSRF_TRUSTED_ORIGINS environment-only This prevents weak/default SECRET_KEYs from being used in production. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
"""
|
|
Development settings for KeepItGoing.
|
|
|
|
Use this for local development.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from django.core.management.utils import get_random_secret_key
|
|
from .base import *
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
# Generate a random key for development on each startup if not provided
|
|
SECRET_KEY = os.environ.get('SECRET_KEY')
|
|
if not SECRET_KEY:
|
|
SECRET_KEY = get_random_secret_key()
|
|
print(f"WARNING: Using auto-generated SECRET_KEY for development. Set SECRET_KEY env var to persist sessions.", file=sys.stderr)
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
# Development-only hosts - production domains should NOT be here
|
|
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '[::1]', '10.0.2.2', '192.168.1.241']
|
|
|
|
# CSRF - for development testing only
|
|
CSRF_TRUSTED_ORIGINS = os.environ.get('CSRF_TRUSTED_ORIGINS', '').split(',') if os.environ.get('CSRF_TRUSTED_ORIGINS') else []
|
|
|
|
# Database - SQLite for development
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
}
|
|
}
|
|
|
|
# Redis/Celery - use memory broker for development if Redis not available
|
|
CELERY_BROKER_URL = os.environ.get('REDIS_URL', 'memory://')
|
|
CELERY_RESULT_BACKEND = os.environ.get('REDIS_URL', 'cache+memory://')
|
|
|
|
# CORS - allow all in development
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
|
|
|
# Email - console backend for development
|
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
|
|
|
# Logging
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'formatters': {
|
|
'verbose': {
|
|
'format': '{levelname} {asctime} {module} {message}',
|
|
'style': '{',
|
|
},
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'verbose',
|
|
},
|
|
},
|
|
'root': {
|
|
'handlers': ['console'],
|
|
'level': 'INFO',
|
|
},
|
|
'loggers': {
|
|
'django': {
|
|
'handlers': ['console'],
|
|
'level': 'INFO',
|
|
'propagate': False,
|
|
},
|
|
},
|
|
}
|