Add phase 1: Docker setup, auth with invitations and roles
- Django 5.2 + PostgreSQL 17 via docker compose (app + db, volumes, healthcheck on /healthz, test profile running pytest against Postgres) - Custom e-mail user model with user/admin roles - Invitation-only registration with single-use, hashed, expiring links - Admin area: invitations, role changes, deactivation, password reset via one-time link or temporary password (forced change on login) - First admin created from ADMIN_EMAIL/ADMIN_PASSWORD on startup - Login rate limiting per e-mail and IP (DB-backed, worker-safe) - Proxy middleware honouring X-Forwarded-* only from TRUSTED_PROXIES, optional CLIENT_IP_HEADER (e.g. CF-Connecting-IP) - Security headers (CSP, HSTS, Permissions-Policy), secure __Host- cookies - Mobile-first German UI, CLAUDE.md, README, init-env script - 65 tests for auth, permissions, proxy handling and rate limiting Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# Kopieren nach .env und anpassen: cp .env.example .env
|
||||
# Pflichtwerte sind mit [PFLICHT] markiert.
|
||||
|
||||
# --- Allgemein ---------------------------------------------------------------
|
||||
# [PFLICHT] Langer Zufallswert, z. B.: openssl rand -base64 48
|
||||
SECRET_KEY=
|
||||
# [PFLICHT] Öffentliche Adresse, wie sie im Browser steht (für Einladungslinks, CSRF, Hosts)
|
||||
APP_BASE_URL=https://kochbuch.dammann.vip
|
||||
# Zusätzliche erlaubte Hostnamen (kommagetrennt), z. B. für direkten LAN-Zugriff
|
||||
ALLOWED_HOSTS=
|
||||
TIME_ZONE=Europe/Berlin
|
||||
# Nur für lokale Entwicklung auf true setzen
|
||||
DEBUG=false
|
||||
|
||||
# --- Netzwerk / Reverse Proxy ------------------------------------------------
|
||||
# Port auf dem Host, auf dem die App erreichbar ist (HTTP, ohne TLS)
|
||||
APP_PORT=8000
|
||||
# Adresse, an die der Port gebunden wird (127.0.0.1 = nur lokal, 0.0.0.0 = alle Interfaces)
|
||||
APP_BIND_ADDRESS=0.0.0.0
|
||||
# IPs/Netze (CIDR, kommagetrennt), deren X-Forwarded-For/-Proto-Header vertraut wird.
|
||||
# Standard: private Netze. Am besten auf die IP deines Nginx eingrenzen.
|
||||
TRUSTED_PROXIES=127.0.0.1/32,::1/128,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
|
||||
# Optional: Header mit der echten Client-IP, gesetzt von einem vertrauenswürdigen Proxy,
|
||||
# z. B. CF-Connecting-IP bei Cloudflare. Leer = X-Forwarded-For auswerten.
|
||||
CLIENT_IP_HEADER=
|
||||
# Cookies nur über HTTPS senden. Nur für Tests ohne HTTPS auf false setzen.
|
||||
COOKIE_SECURE=true
|
||||
# HSTS-Dauer in Sekunden (0 = aus)
|
||||
HSTS_SECONDS=31536000
|
||||
|
||||
# --- Erster Admin (wird beim Start angelegt, falls die E-Mail noch nicht existiert) ---
|
||||
ADMIN_EMAIL=
|
||||
ADMIN_PASSWORD=
|
||||
ADMIN_NAME=Admin
|
||||
|
||||
# --- Datenbank ---------------------------------------------------------------
|
||||
POSTGRES_DB=kochbuch
|
||||
POSTGRES_USER=kochbuch
|
||||
# [PFLICHT] z. B.: openssl rand -base64 32
|
||||
POSTGRES_PASSWORD=
|
||||
|
||||
# --- Server-Ressourcen ---------------------------------------------------------
|
||||
GUNICORN_WORKERS=2
|
||||
GUNICORN_THREADS=4
|
||||
GUNICORN_TIMEOUT=120
|
||||
|
||||
# --- Anmelde-Schutz ------------------------------------------------------------
|
||||
# Fehlversuche pro E-Mail bzw. pro IP innerhalb des Zeitfensters (Minuten)
|
||||
LOGIN_MAX_FAILURES_PER_EMAIL=5
|
||||
LOGIN_MAX_FAILURES_PER_IP=30
|
||||
LOGIN_LOCKOUT_MINUTES=15
|
||||
Reference in New Issue
Block a user