SECRET_KEY: verständliche Fehlermeldung mit Befehl zum Erzeugen eines gültigen Schlüssels
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
# ── Pflicht ───────────────────────────────────────────────────────────────────
|
# ── Pflicht ───────────────────────────────────────────────────────────────────
|
||||||
# Datenbank: Postgres (docker-compose setzt sie selbst) oder SQLite für lokale Entwicklung
|
# Datenbank: Postgres (docker-compose setzt sie selbst) oder SQLite für lokale Entwicklung
|
||||||
DATABASE_URL=sqlite:///./.data/onyscribe-admin.db
|
DATABASE_URL=sqlite:///./.data/onyscribe-admin.db
|
||||||
# Master-Key für Secrets in der DB UND Session-Cookies (Fernet-Key). SICHERN – ohne ihn sind Secrets unlesbar.
|
# Master-Key für Secrets in der DB UND Session-Cookies (Fernet-Key, 44 Zeichen). SICHERN – ohne ihn sind Secrets unlesbar.
|
||||||
|
# python3 -c "import base64,os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())"
|
||||||
# python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
|
# python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
|
||||||
SECRET_KEY=
|
SECRET_KEY=
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,14 @@ from cryptography.fernet import Fernet
|
|||||||
|
|
||||||
from app.settings import SECRET_KEY
|
from app.settings import SECRET_KEY
|
||||||
|
|
||||||
_f = Fernet(SECRET_KEY.encode())
|
try:
|
||||||
|
_f = Fernet(SECRET_KEY.encode())
|
||||||
|
except ValueError as exc:
|
||||||
|
raise RuntimeError(
|
||||||
|
"SECRET_KEY ist kein gültiger Fernet-Schlüssel (erwartet: 32 Zufallsbytes in URL-sicherem Base64, 44 Zeichen, endet meist mit „=“). "
|
||||||
|
"Erzeugen mit: python3 -c \"import base64,os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())\" "
|
||||||
|
"– und in Coolify als SECRET_KEY setzen (außerhalb von Coolify sichern; ohne ihn sind die Secrets in der Datenbank nicht entschlüsselbar)."
|
||||||
|
) from exc
|
||||||
|
|
||||||
|
|
||||||
def encrypt(v: str) -> str:
|
def encrypt(v: str) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user