186 lines
13 KiB
Bash
186 lines
13 KiB
Bash
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Parafa — copy to .env and edit. On Windows write it WITHOUT a BOM:
|
|
# [System.IO.File]::WriteAllText("$PWD\.env", (Get-Content .env.example -Raw))
|
|
# (PowerShell's Out-File -Encoding utf8 adds a BOM, which pydantic-settings then
|
|
# folds into the first key name and you get a baffling "field required" error.)
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
# Core. Defaults fail closed: production hides error detail. The session cookie's
|
|
# Secure flag is auto-detected from the request scheme (see SESSION_COOKIE_SECURE).
|
|
APP_ENV=production
|
|
APP_BASE_URL=http://localhost
|
|
# Path prefix this deployment is mounted under. Empty = served at the origin root (this stack).
|
|
# ROOT_PATH=/parafa runs it as a module of a platform (one origin, one module per path). It is
|
|
# HALF of one decision: the front door must STRIP the prefix (Atrium forwards `/parafa/*` without it) and
|
|
# this backend re-adds it via uvicorn --root-path. Set only one of the two and you get a doubled
|
|
# prefix (404s everywhere) or server-generated URLs that escape it. The console needs nothing — it
|
|
# derives its API base from the document.
|
|
ROOT_PATH=
|
|
|
|
# ── Database ─────────────────────────────────────────────────────────────────
|
|
# Runtime uses the least-privilege `app` role; Alembic uses `migrator`.
|
|
POSTGRES_DB=parafa
|
|
POSTGRES_PASSWORD=change_me_super
|
|
DB_APP_PASSWORD=change_me_app
|
|
DB_MIGRATOR_PASSWORD=change_me_migrator
|
|
|
|
DATABASE_URL=postgresql+pg8000://app:change_me_app@postgres:5432/parafa
|
|
MIGRATION_DATABASE_URL=postgresql+pg8000://migrator:change_me_migrator@postgres:5432/parafa
|
|
# The runtime role's name (the user in DATABASE_URL); the runtime-grants migration grants to it.
|
|
DB_APP_ROLE=app
|
|
# The backend's connection pool: at most DB_POOL_SIZE + DB_MAX_OVERFLOW connections.
|
|
DB_POOL_SIZE=5
|
|
DB_MAX_OVERFLOW=10
|
|
# TLS rule: a database host that is not local ("", localhost, 127.0.0.1, ::1 or `postgres`) must say
|
|
# sslmode=verify-full in its URL, or the backend, migrate and the seed refuse to start. A private
|
|
# database on a trusted network that truly needs no TLS is listed here instead (comma-separated).
|
|
# No other opt-out.
|
|
DB_LOCAL_HOSTS=
|
|
|
|
# ── Managed PostgreSQL (the family's shared database; replaces the local postgres) ──
|
|
# Runbook: db/managed/README.md. Every app of the family shares ONE managed database; Parafa
|
|
# lives in schema parafa, as roles parafa_migrator and parafa_app. Provision it
|
|
# once, then replace the Database settings above with these, delete the POSTGRES_PASSWORD and
|
|
# DB_*_PASSWORD lines (unused there), and start with BOTH compose files:
|
|
# docker compose -f docker-compose.yml -f docker-compose.managed-db.yml up -d --build
|
|
# - Host and port: from the provider's connection details. Through a pooler use its SESSION mode
|
|
# (transaction mode breaks prepared statements; on the poolers the family knows that is port 5432,
|
|
# never 6543), or the direct connection.
|
|
# - User: <role>, or <role>.<tenant> where the pooler wants the tenant in the user name. Never the
|
|
# platform admin (postgres).
|
|
# - TLS: sslmode=verify-full against the provider's root CA (downloaded from its dashboard), which the
|
|
# override mounts at /run/certs/db-ca.crt from MANAGED_DB_CA_FILE; leave sslrootcert out to verify
|
|
# against the system trust store instead. sslmode=prefer/allow/disable are refused, and so is a
|
|
# URL to any host that is not local without sslmode=verify-full (DB_LOCAL_HOSTS above).
|
|
# - Passwords: percent-encode every character outside A-Z a-z 0-9 - . _ ~ (e.g. @ -> %40, % -> %25).
|
|
# - DB_APP_ROLE: the role in DATABASE_URL without any .<tenant> suffix (migrate refuses otherwise).
|
|
# - Pool: count DB_POOL_SIZE + DB_MAX_OVERFLOW + 1 (a seed or check beside the backend) per app, and
|
|
# keep the total over every app in the database at or below 80% of its connection limit (the
|
|
# provider's own services use the rest): 72 of 90, 48 of 60. Five apps at the defaults take
|
|
# 5 x (15 + 1) = 80, which does NOT fit a 90-connection limit: set DB_POOL_SIZE=4 and
|
|
# DB_MAX_OVERFLOW=8 in EVERY app (5 x 13 = 65), or size the instance for more. For a 60-connection
|
|
# limit set DB_POOL_SIZE=3 and DB_MAX_OVERFLOW=2 in EVERY app (5 x 6 = 30). Through a pooler in
|
|
# session mode, its own pool size must be at least DB_POOL_SIZE + DB_MAX_OVERFLOW + 1.
|
|
# DB_POOL_SIZE >= 1 and DB_MAX_OVERFLOW >= 0 (0 / -1 would mean no limit, so they are refused).
|
|
# MANAGED_DB_CA_FILE=./certs/db-ca.crt
|
|
# DATABASE_URL=postgresql+pg8000://parafa_app.<tenant>:<app-password>@<host>:5432/postgres?sslmode=verify-full&sslrootcert=/run/certs/db-ca.crt
|
|
# MIGRATION_DATABASE_URL=postgresql+pg8000://parafa_migrator.<tenant>:<migrator-password>@<host>:5432/postgres?sslmode=verify-full&sslrootcert=/run/certs/db-ca.crt
|
|
# DB_APP_ROLE=parafa_app
|
|
# DB_POOL_SIZE=4
|
|
# DB_MAX_OVERFLOW=8
|
|
|
|
# ── Storage ──────────────────────────────────────────────────────────────────
|
|
DATA_DIR=/data
|
|
|
|
# ── Galena (optional) ────────────────────────────────────────────────────────
|
|
# Galena's PUBLIC base URL (https://<site>/galena). Empty = no Galena: requests are uploaded PDFs
|
|
# only, and a request on a Galena document answers 409 galena_disabled (D9). Set, a request may name
|
|
# a Galena document, and its signed PDF is written back there as a new version, with the person's
|
|
# own token.
|
|
GALENA_BASE_URL=
|
|
|
|
# ── The signer (PAdES) ───────────────────────────────────────────────────────
|
|
# The operator's certificate + key as ONE PKCS#12 file, mounted read-only (compose mounts
|
|
# PARAFA_SIGNER_DIR at /run/parafa-signer). Never commit it; never bake it into an image. The
|
|
# passphrase preferably from a secret FILE; SIGNING_PKCS12_PASSPHRASE is the fallback.
|
|
# Empty path = signing off: requests and verification work, "Podpisz" answers 409.
|
|
SIGNING_PKCS12_PATH=
|
|
SIGNING_PKCS12_PASSPHRASE_FILE=
|
|
SIGNING_PKCS12_PASSPHRASE=
|
|
# PEM bundle of CA certificates a verification trusts (empty = "trusted" is always no).
|
|
SIGNING_TRUST_ROOTS=
|
|
# /Location in the signature dictionary (optional).
|
|
SIGNING_LOCATION=
|
|
# Who may sign, comma-separated, the first the default: local (the PKCS#12 seal above) and signudoc
|
|
# (SignuDoc; no API in the Start edition, so: download, sign there, upload the signed PDF).
|
|
SIGNING_PROVIDERS=local,signudoc
|
|
|
|
# ── One platform, one account ────────────────────────────────────────────────
|
|
# The shared identity schema. Empty — this stack — is STANDALONE: Parafa owns its own
|
|
# accounts, has its own sign-in screen and its own Users administration, and the three settings
|
|
# below do nothing. That is a supported deployment for ever, not a stage to grow out of.
|
|
#
|
|
# Set IDENTITY_SCHEMA=dredd and this app becomes a MODULE of the platform: `app_user`,
|
|
# `session` and `module_permission` live in a neutral schema the hub owns and this app READS. A
|
|
# person then has ONE account for everything, signs in once at the hub, and the cookie they got
|
|
# there is the cookie this app accepts — one origin, one cookie, nothing to hand over. This app's
|
|
# sign-in form disappears (there is no password here), account creation and password changes answer
|
|
# 409 pointing at the hub, and app tokens stay listable and revocable but are minted there.
|
|
#
|
|
# It also starts REFUSING people, which standalone it never does. `module_permission` holds one row
|
|
# per person per module, and no row is no access: somebody with a platform account who has not been
|
|
# admitted to this one is turned away at the door rather than shown an empty screen. Admitting them,
|
|
# and making somebody a moderator of this app, happens in the hub — this app holds SELECT on that
|
|
# table and nothing else.
|
|
#
|
|
# Switching it on is NOT just this line. In order: the platform admin re-renders
|
|
# db/managed/provision.sql with --identity-schema / --identity-owner and runs it (the schema, USAGE
|
|
# and a search_path of `parafa, dredd, extensions` — none of which a migrator may
|
|
# do); the hub's own migration creates the tables and grants this app's two roles their tier; then
|
|
# `alembic upgrade head` here runs 0003, which merges this schema's accounts into the shared ones by
|
|
# e-mail address. Read backend/alembic/versions/0003_shared_identity.py before running it on
|
|
# anything you care about — it drops this app's local identity tables, and every session and app
|
|
# token with them. db/managed/README.md has the whole sequence.
|
|
IDENTITY_SCHEMA=
|
|
# This app's slug on the platform — the module a permission row admits somebody to. Only meaningful
|
|
# with IDENTITY_SCHEMA set, and it must match the slug the hub uses for this app, or nobody's row
|
|
# resolves and nobody but a platform administrator can open it. Note it is NOT always the same
|
|
# string as the Postgres schema (`parafa`): a module slug is a URL path segment, so the hub's
|
|
# module_permission table allows hyphens and refuses underscores, while a schema name is the other
|
|
# way round. The scaffolder derived this one from that one; change both or neither.
|
|
MODULE_SLUG=parafa
|
|
# Where people sign in when accounts are shared: the hub's address as a browser sees it, e.g.
|
|
# /atrium/. Empty is allowed — the console then says accounts live elsewhere without offering a
|
|
# link that goes nowhere.
|
|
IDENTITY_HUB_URL=
|
|
# The session cookie's name. One account means one cookie: at a cutover every app in the family is
|
|
# set to dredd_session. The old name is still read for a while, so renaming it does not sign
|
|
# everybody out the moment the container restarts.
|
|
SESSION_COOKIE_NAME=parafa_session
|
|
|
|
# ── Auth / sessions ──────────────────────────────────────────────────────────
|
|
SESSION_TTL_HOURS=12
|
|
LOGIN_MAX_ATTEMPTS=5
|
|
LOGIN_LOCKOUT_MINUTES=15
|
|
# Empty = auto-detect from the request scheme (Secure over HTTPS only). Never key
|
|
# this off APP_ENV — a Secure cookie over plain HTTP is dropped and login "doesn't stick".
|
|
SESSION_COOKIE_SECURE=
|
|
|
|
# CORS — empty by default (same-origin design). Comma-separated origins for a
|
|
# separately-served console in dev.
|
|
CORS_ALLOW_ORIGINS=
|
|
|
|
# Who may frame Parafa: 'none' (default; X-Frame-Options DENY) or 'self' (SAMEORIGIN, what the
|
|
# platform's kit sets). Anything else refuses start-up.
|
|
FRAME_ANCESTORS='none'
|
|
|
|
# ── Bootstrap admin (seed) ───────────────────────────────────────────────────
|
|
BOOTSTRAP_ADMIN_EMAIL=admin@example.com
|
|
BOOTSTRAP_ADMIN_PASSWORD=admin12345
|
|
# Seed a small demo dataset so the app isn't empty on first run.
|
|
SEED_DEMO=true
|
|
|
|
# ── App tokens ───────────────────────────────────────────────────────────────
|
|
# Named, revocable credentials for desktop/CLI clients, so they never store a password.
|
|
# The window is an IDLE timeout: every use slides it forward, so a token in regular use keeps
|
|
# working while one that is exfiltrated and parked expires on its own.
|
|
APP_TOKENS_ENABLED=true
|
|
APP_TOKEN_IDLE_DAYS=30
|
|
APP_TOKEN_MAX_IDLE_DAYS=365
|
|
APP_TOKEN_RENEW_AFTER_HOURS=12
|
|
|
|
# ── The edge ─────────────────────────────────────────────────────────────────
|
|
# No reverse proxy: the backend is published on :80 (plain HTTP) and is its own edge (app/edge.py).
|
|
# uvicorn trusts X-Forwarded-For only from these addresses (default 127.0.0.1). On the platform, the
|
|
# front door's address; never `*`.
|
|
FORWARDED_ALLOW_IPS=127.0.0.1
|
|
|
|
# ── OpenTelemetry (opt-in) ───────────────────────────────────────────────────
|
|
OTEL_ENABLED=false
|
|
OTEL_SERVICE_NAME=parafa-backend
|
|
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
|
|
|
|
# The Archive's technical account (Atrium#53): the fixed id the hub creates it under. Here it may
|
|
# reach only the evidence routes (GET /evidence, POST /seal); everywhere else it is a 404. Keep the default.
|
|
ARCHIVE_READER_ID=a2c41e00-0000-4000-8000-000000000053
|