Jun 26 MT-1 phase

This commit is contained in:
2026-06-26 16:37:44 -04:00
parent fc39491891
commit 07cf2e5816
9 changed files with 300 additions and 55 deletions
+21
View File
@@ -31,6 +31,27 @@ class Config:
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = False
# ── Multi-tenancy (MT-1) ─────────────────────────────────────────────────
# Master switch. When False (default) the app behaves EXACTLY as the
# single-tenant deployment: no Host resolution, every query uses
# SQLALCHEMY_DATABASE_URI. Flip to True only after tenants are registered
# in the control plane (see MULTI_TENANT_PLAN.md). The control plane env
# vars (CONTROL_DATABASE_URL, CONTROL_FERNET_KEY) are only required when
# this is True.
MULTI_TENANT_ENABLED = os.environ.get(
'MULTI_TENANT_ENABLED', 'false'
).strip().lower() in ('1', 'true', 'yes', 'on')
# Path prefixes that bypass the tenant gate even when enabled (e.g. health
# checks). '/static/' is always exempt. Comma-separated in the environment.
MULTI_TENANT_EXEMPT_PATHS = [
p.strip() for p in os.environ.get('MULTI_TENANT_EXEMPT_PATHS', '').split(',')
if p.strip()
]
# Per-tenant SQLAlchemy engine pool tuning (see MULTI_TENANT_PLAN.md §4).
TENANT_ENGINE_POOL_SIZE = int(os.environ.get('TENANT_ENGINE_POOL_SIZE', 5))
TENANT_ENGINE_MAX_OVERFLOW = int(os.environ.get('TENANT_ENGINE_MAX_OVERFLOW', 5))
TENANT_ENGINE_POOL_RECYCLE = int(os.environ.get('TENANT_ENGINE_POOL_RECYCLE', 1800))
# ── File uploads ────────────────────────────────────────────────────────
UPLOAD_FOLDER = os.path.join(basedir, 'app/static/uploads')
MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50 MB