- Separate admin login (ADMIN_USERNAME/ADMIN_PASSWORD) with its own JWT, no longer a seeded user account; lockout after 5 failed attempts - Admin panel tabs: Users, Notifications, Backups, Reset - Ntfy settings moved from .env/compose into admin_settings (token encrypted) - Scheduled and on-demand mariadb-dump backups to NFS volume, with restore (entries only or all) and retention pruning - Reset all entries, guarded by an automatic safety backup - Remove user impersonation and the admin link in the user nav - Login page falls back to admin login; nginx sends Cache-Control: no-cache Co-Authored-By: Claude Opus 5.5 <[email protected]>
22 lines
554 B
Python
22 lines
554 B
Python
import base64
|
|
import hashlib
|
|
|
|
from cryptography.fernet import Fernet
|
|
|
|
from app.config import settings
|
|
|
|
|
|
def _fernet() -> Fernet:
|
|
# Derived from SECRET_KEY: rotating SECRET_KEY also invalidates any
|
|
# previously encrypted values (e.g. the stored ntfy token).
|
|
key = hashlib.sha256(settings.secret_key.encode()).digest()
|
|
return Fernet(base64.urlsafe_b64encode(key))
|
|
|
|
|
|
def encrypt(value: str) -> str:
|
|
return _fernet().encrypt(value.encode()).decode()
|
|
|
|
|
|
def decrypt(value: str) -> str:
|
|
return _fernet().decrypt(value.encode()).decode()
|