Move email SMTP config to settings page with encrypted password storage; add cryptography dependency

This commit is contained in:
Troll (Hermes Agent) 2026-08-01 23:20:23 +00:00
parent 5277c20d24
commit 8e5c2f5867
5 changed files with 160 additions and 57 deletions

View file

@ -3,14 +3,13 @@ config.py
=========
Configuration object loaded by Flask from environment variables.
The application expects values to be provided via Portainer environment
variables or a local .env file during development.
Most operational settings are now editable at runtime from /admin/settings
and stored in booth_settings.json on disk. Sensitive email credentials are
encrypted with the Flask SECRET_KEY when saved.
All values have sensible defaults where safe, but the following MUST be
set in production:
- APP_SECRET_KEY
- ADMIN_PASSWORD
- SMTP_PASS
Required environment values:
- APP_SECRET_KEY (used to sign sessions and encrypt stored settings)
- ADMIN_PASSWORD (plain-text login password)
- PUBLIC_BASE_URL
"""
@ -22,7 +21,7 @@ load_dotenv()
class Config:
# Flask secret key: used to sign session cookies. Must be a long random string in production.
# Flask secret key: used to sign session cookies and encrypt stored credentials.
SECRET_KEY = os.environ.get('APP_SECRET_KEY', 'dev-secret-change-me')
# SQLite database path inside the container.
@ -31,10 +30,14 @@ class Config:
# Directory where uploaded MP3 files are stored inside the container.
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER', '/app/uploads')
# Runtime settings file: stored next to the upload folder for persistence.
SETTINGS_FILE = os.environ.get('SETTINGS_FILE', 'booth_settings.json')
# Only MP3 uploads are allowed.
ALLOWED_EXTENSIONS = {'mp3'}
# SMTP server settings for sending customer emails.
# Default SMTP server settings for sending customer emails.
# These can be overridden from /admin/settings and stored encrypted.
SMTP_HOST = os.environ.get('SMTP_HOST', 'mailroot8.namespro.ca')
SMTP_PORT = int(os.environ.get('SMTP_PORT', '465'))
SMTP_USER = os.environ.get('SMTP_USER', 'ai@hallsworth.ca')
@ -44,12 +47,6 @@ class Config:
# Admin login password (plain text, set via env).
ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', '')
# Optional operator alert email. Currently unused because the dashboard is the queue.
ADMIN_ALERT_EMAIL = os.environ.get('ADMIN_ALERT_EMAIL', '')
# Maximum number of revision rounds a customer is allowed to request automatically.
MAX_REVISIONS = int(os.environ.get('MAX_REVISIONS', '2'))
# Public HTTPS URL used in customer emails and QR codes.
PUBLIC_BASE_URL = os.environ.get('PUBLIC_BASE_URL', 'http://127.0.0.1:5000')