Platform v2 step 1.4 (APPS_PLATFORM D-3..D-6, D-21, §5). - core/modules/entitlements.py: compute() turns the evaluated license into per-module grants: the v2 token's `modules` map (own `exp` with the 5-day grace, never cut mid-service) + the free tier; no/invalid token, expired after grace, inactive, locked or clock tampering -> free tier only; core always. limit(module, name) with token value -> manifest licensed_default -> free value; None = unlimited. LICENSE_MODE=off (dev/test only) = everything - module gating says why: module.not_licensed (402, the first unlicensed module in the dependency chain) before module.disabled (403) - services/license.py accepts only v2 tokens with a modules map; the v1 "legacy unsigned 72h" path is gone - apply_license() always installs entitlements (startup before workers, every heartbeat, workday close); workers follow license changes - the global license middleware is deleted (no more whole-API 402/423); license_state moved to services/license_state.py - history_days enforced in every report/history endpoint: lower date bounds clamped (also when no "from" is given), and business days older than the limit refused by id (license.history_limited); data is never deleted - bootstrap/modules API show license mode, entitlement source and limit values - LICENSE_MODE=off in docker-compose.dev.yml and the e2e launchers; sites default to enforced - tests: entitlement rules, limits, the three done-when checks, signed-token apply_license path; license tests moved to v2 tokens Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import os
|
|
from pathlib import Path
|
|
from pydantic_settings import BaseSettings
|
|
|
|
_HERE = Path(__file__).parent # always points to local_backend/
|
|
|
|
# Use AppData on Windows (avoids Controlled Folder Access blocks),
|
|
# fall back to local_backend/ on Linux/Mac/Docker
|
|
if os.name == "nt":
|
|
_DB_DEFAULT = Path(os.environ.get("LOCALAPPDATA", Path.home() / "AppData" / "Local")) / "pos" / "pos.db"
|
|
_DB_DEFAULT.parent.mkdir(parents=True, exist_ok=True)
|
|
else:
|
|
_DB_DEFAULT = _HERE / "pos.db"
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
SITE_ID: str = ""
|
|
SITE_KEY: str = ""
|
|
CLOUD_URL: str = ""
|
|
SECRET_KEY: str = "change-me-generate-a-long-random-string"
|
|
DATABASE_URL: str = f"sqlite:///{_DB_DEFAULT.as_posix()}"
|
|
VERSION: str = "0.3.1"
|
|
CONNECT_SYNC_INTERVAL_SECONDS: int = 30 # how often to poll for pending online orders
|
|
# Licensing (APPS_PLATFORM D-3..D-6). "enforced": modules come from the signed v2
|
|
# token, or the free tier without one. "off": every module, no limits; ONLY for dev
|
|
# machines and test suites (docker-compose.dev.yml, tests/e2e). Never on a site.
|
|
LICENSE_MODE: str = "enforced"
|
|
|
|
# Break-glass master account — lives only in env vars, never in the DB
|
|
MASTER_USERNAME: str = ""
|
|
MASTER_PASSWORD: str = ""
|
|
|
|
model_config = {"env_file": str(_HERE / ".env"), "env_file_encoding": "utf-8"}
|
|
|
|
|
|
settings = Settings()
|