banyaro/backend
rene 9394bab1fb Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095
SECURITY (auth.py, routes/auth.py, database.py, main.py)
- JWT bekommt jti; Logout trägt in neue jwt_blacklist-Tabelle ein,
  decode_token() prüft → server-side Invalidierung
- JWT-Expiry default 30 → 7 Tage (ENV JWT_EXPIRY_DAYS überschreibt)
- Sliding-Refresh-Middleware: erneuert Cookie wenn >50% verbraucht
  (Schwelle via JWT_REFRESH_FRACTION, Default 2)
- Login-Lockout in DB-Tabelle login_attempts (5 Versuche / 15 Min,
  überlebt Container-Restart) — alte In-Memory-Lockouts ersetzt
- SMTP-Versand: alle 'except: pass' durch logger.exception ersetzt;
  Fehlversuche landen in failed_emails-Tabelle für späteres Retry
- Referral-Counter Race gefixt: UPDATE partner_codes SET uses=uses+1
  ... WHERE uses<max_uses RETURNING — atomar statt SELECT+UPDATE

RACE CONDITIONS (routes/invoices.py, database.py)
- Neue invoice_counters-Tabelle für atomare Nummernvergabe
- _next_invoice_number nutzt BEGIN IMMEDIATE + atomares UPDATE
- Funktioniert für RG- und ST-Prefixe (Stornorechnungen)
- Race-Test verifiziert (5 Threads × 20 Calls = 100 eindeutige Nummern)

VERSION + TESTS + ERROR-DIGEST (VERSION, Makefile, tests/, scheduler.py)
- Neue VERSION-Datei (Single Source of Truth) — main.py liest beim
  Startup
- Makefile-Target 'make bump' propagiert in sw.js, app.js, index.html
- Makefile-Target 'make test' setzt venv auf, läuft pytest
- 19 Smoke-Tests in tests/ (health, auth, diary, invoice) — alle grün
- Scheduler: täglicher _job_error_digest um 06:30 → schickt Error-
  Zusammenfassung an ADMIN_EMAIL (still wenn keine Errors)

DSGVO + A11Y + ERSTE-HILFE
- landing.html: 'HTML und ODS' → 'JSON' (tatsächlich implementiert)
- datenschutz.js: Sektion Account-Löschung erweitert (sofort gelöscht /
  anonymisiert / 10 Jahre für Rechnungen)
- erste-hilfe.js: prominentes Warning-Banner oben (ersetzt keine
  Tierarzt-Beratung); Notfallnummern gruppiert nach Land, TODO-Platz-
  halter für AT-Uni-Klinik, CH Tox Info Suisse, CH Tierspital Zürich
- ui.js Modal: ESC schließt, Focus-Trap, Auto-Focus erstes Element,
  Restore Focus auf vorigen Caller
- impressum.js Kontaktformular: Labels mit for=cf-name etc.

NEUE DB-TABELLEN (idempotent via CREATE TABLE IF NOT EXISTS)
- jwt_blacklist, login_attempts, failed_emails, invoice_counters

NEUE ENV-VARS
- JWT_REFRESH_FRACTION (Default 2)
- JWT_EXPIRY_DAYS Default geändert (30 → 7)
2026-05-26 20:12:01 +02:00
..
routes Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
scraper Fix: VDH-Fallback-Events aktualisiert — Frankfurt Mai entfernt (vergangen), 7 korrekte Termine 2026 2026-05-08 13:52:37 +02:00
scripts Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
static Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
auth.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
cache.py Perf: 9 Performance-Fixes — SW by-v1072 2026-05-26 06:30:36 +02:00
content_filter.py Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
database.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
entrypoint.sh Revert Dockerfile USER appuser (Synology DSM ACL inkompatibel) 2026-04-23 18:52:51 +02:00
generate_thumbs.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
ki.py Fix: KI health_summary Kontextfenster (max 5 Einträge), Cloud-Priority ohne ANTHROPIC_KEY-Check, local-Fallback wrapped (SW by-v798) 2026-05-09 20:08:06 +02:00
mailer.py Fix: Date-Header in ausgehenden Mails (formatdate UTC, Container hat keine lokale TZ) 2026-05-15 12:37:41 +02:00
main.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
media_utils.py Fix: Karte lädt wieder + safe_media_path + Foto-Löschung (SW by-v932) 2026-05-14 11:58:00 +02:00
migrate_media.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
ratelimit.py Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
requirements.txt Chore: Sprint32-36 Zwischenstand — alle Änderungen aus dieser Session committen 2026-05-03 11:09:39 +02:00
scheduler.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
timeutils.py Teil 3: Terminvorschläge + KI-Limit-Bypass für Admins/Mods — SW by-v435, APP_VER 414 2026-04-26 17:08:18 +02:00
username_blocklist.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
weather.py Fix: Asphalttemperatur-Formel temperaturabhängig (t_factor 0..1 zwischen 5-30°C), nicht mehr temperaturblind 2026-05-16 13:53:05 +02:00
welfare_check.py Feature: Tierschutz-Check, KI-Züchter-Features, Export, SEO-Update 2026-04-28 19:49:54 +02:00