Files
ops-docs/reference/env-manifest.md

130 lines
9.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Reference — Member portal environment-variable manifest
Generated 2026-11-11 from the RUNNING portal container's environment (69 vars,
read as NAMES only — no values were printed or committed), the portal source
(`app/main.py` reads at the line numbers cited), and fingerprint comparison
(`sha256`[:8]) between the portal's copies and each owner app's own
credential. Companion to the incident
[`2026-11-05-portal-alltime-spend-zero.md`](../incidents/2026-11-05-portal-alltime-spend-zero.md),
which is why the copy-pattern secrets carry a warning.
Reading guide:
- **Source** — where the value comes from at runtime:
`platform` = injected by Cloudron (not in any repo, do not set by hand);
`app env` = set on the portal app via the Cloudron env API / dashboard
(42 vars; the authoritative values live in the platform, never in git);
`image` = baked in by the base python image, irrelevant to the app.
- **Class** — `SECRET` (credential: treat as rotation-sensitive),
`IDENT` (identifier/URL: safe-ish, still internal), `CONFIG` (behaviour flag).
- **COPY** — the value is a *copy* of another app's or system's credential.
A rotation or restore on the OWNER side silently rots the copy (proven by the
2026-11-05 incident). After any owner-side restore/rotation, re-sync the copy
and diff fingerprints — never values.
## 1. Platform-injected (27) — never set by hand
| Name | Source | Class | Read by portal | Notes |
|---|---|---|---|---|
| `CLOUDRON_API_ORIGIN` | platform | IDENT | yes (L198) | Cloudron API base the portal calls for OIDC user lookups |
| `CLOUDRON_APP_BRIDGE_ORIGIN` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_APP_DOMAIN` | platform | IDENT | no | portal.inference.coop |
| `CLOUDRON_APP_HOSTNAME` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_APP_ORIGIN` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_MAIL_DOMAIN` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_MAIL_FROM` | platform | IDENT | yes (L474) | From identity for portal mail (default `info@inference.coop`) |
| `CLOUDRON_MAIL_SMTP_PASSWORD` | platform | SECRET | yes (L473) | Cloudron mail addon relay password |
| `CLOUDRON_MAIL_SMTP_PORT` | platform | IDENT | yes (L471) | relay submission port |
| `CLOUDRON_MAIL_SMTP_SERVER` | platform | IDENT | yes (L470) | relay host |
| `CLOUDRON_MAIL_SMTP_USERNAME` | platform | SECRET | yes (L472) | relay user |
| `CLOUDRON_MAIL_SMTPS_PORT` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_MAIL_STARTTLS_PORT` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_OIDC_AUTH_ENDPOINT` | platform | IDENT | no | read via OIDC discovery, not directly |
| `CLOUDRON_OIDC_CLIENT_ID` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_CLIENT_SECRET` | platform | SECRET | no | consumed by the OIDC discovery flow |
| `CLOUDRON_OIDC_DISCOVERY_URL` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_ISSUER` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_KEYS_ENDPOINT` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_PROFILE_ENDPOINT` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_PROVIDER_NAME` | platform | IDENT | no | via discovery |
| `CLOUDRON_OIDC_TOKEN_ENDPOINT` | platform | IDENT | no | via discovery |
| `CLOUDRON_PROXY_IP` | platform | IDENT | no | platform plumbing |
| `CLOUDRON_TOKEN` | platform | **SECRET (high)** | yes (L199) | a Cloudron **API token inside an app env** — the portal calls the Cloudron API for group membership. Scope is broader than the app needs; treat as platform-level credential. Owner: the Cloudron platform |
| `CLOUDRON_WEBADMIN_ORIGIN` | platform | IDENT | no | platform plumbing |
| `GPG_KEY` / `PYTHON_VERSION` / `PYTHON_SHA256` | image | IDENT | no | base python image metadata, not the app's |
## 2. Portal app env (42) — set via the Cloudron env API
**The portal's own secrets:**
| Name | Class | Purpose | Notes |
|---|---|---|---|
| `PORTAL_KEK` | SECRET | key-encryption key wrapping member API keys at rest (L44) | owner: portal. Loss = re-provision every member key |
| `ADMIN_TOKEN` | SECRET | `/admin/*` API auth (L252) | consumed by the panel, dashboard and the daily digest |
| `ADMIN_TOKEN_LEGACY` | CONFIG | accepts the legacy admin token alongside `ADMIN_TOKEN` (L253) | `"0"` disables; delete after the panel/dashboard stop sending the old one |
| `BROKER_SECRET` | SECRET | member-API broker auth (L234) | owner: portal |
| `WEBHOOK_TOKEN` | SECRET | inbound webhook auth (L239) | owner: portal |
**COPIES of another system's credentials — the two-copies-of-one-secret risk:**
| Name | Class | Purpose | COPY of (owner) | Risk |
|---|---|---|---|---|
| `LITELLM_DB_HOST`/`_PORT`/`_USER`/`_NAME`/`_PASSWORD` | SECRET/IDENT | direct Postgres read of LiteLLM's ledger for all-time spend, usage, leaderboard (L496–500) | the **gateway's** `CLOUDRON_POSTGRESQL_*` addon env (fingerprint-verified SAME 2026-11-11) | rotates on every gateway restore; rotted 2026-11-05 → $0 spend shown for 2h20m. After any gateway restore: re-sync + fingerprint-diff. Standing alarm: the digest's SPEND CONSISTENCY check reads the gateway side, not this copy |
| `LITELLM_MASTER_KEY` | SECRET | gateway admin API calls from the portal (key seeding, budget caps) (L201) | the **gateway's** `/app/data/.master_key` (fingerprint-verified SAME 2026-11-11: `2cd3668d`) | same rot rule: re-sync after gateway restores |
| `MATRIX_BOT_TOKEN` | SECRET | portal's Matrix bot: invites, space sync, welcome DMs (L441) | the **Synapse server's** registration of the portal bot (matrix.inference.coop) | rotation lives server-side; the copy rots silently |
| `LIBRECHAT_SYNC_TOKEN` | SECRET | token the **key-sync job shares back** — portal `/admin/librechat/keys` requires it (L7645) | shared with the chat app's `sync-keys.js` (chat.inference.coop) | two holders, one value; rotate both together |
| `LISTMONK_API_TOKEN` / `LISTMONK_API_USER` | SECRET | newsletter list sync (L489–490) | the **Listmonk app's** API credentials (newsletter.inference.coop) | owner-side rotation rots the copy |
| `LOOMIO_API_KEY` / `LOOMIO_B3_KEY` | SECRET | Loomio membership + B3 user API (L420, L425) | the **Loomio app's** API keys (forum.inference.coop) | owner-side rotation rots the copy; the 2026-11-04 invite blast came from this integration running live (see that incident) |
| `OC_PERSONAL_TOKEN` | SECRET | Open Collective GraphQL: payments, orders (L331) | the co-op's **Open Collective** account token (external) | external owner; scope-check on rotation |
**Identifiers and config (non-secret):**
| Name | Class | Purpose |
|---|---|---|
| `ADMIN_INVITER_EMAIL`-adjacent `ADMIN_*` — see above | — | — |
| `LITELLM_BASE` | IDENT | gateway base URL (L200, default `https://gateway.inference.coop`) |
| `MATRIX_HOMESERVER` | IDENT | homeserver base (L440) |
| `MATRIX_SPACE_ID` | IDENT | the co-op Space the sync manages (L442) |
| `MATRIX_GENERAL_ROOM` | IDENT | General room id for welcomes (L443) |
| `MATRIX_INVITE_ROOMS` | CONFIG | rooms every new member is invited to (L451) |
| `MATRIX_EXTRA_ROOMS` | CONFIG | additional rooms the bot watches (L454) |
| `MEMBERS_GROUP_ID` | IDENT | Cloudron group id for active members (L401) |
| `INACTIVE_GROUP_ID` | IDENT | Cloudron group id for deactivated members (L405) |
| `GUESTS_GROUP_ID` / `GUESTS_ENDED_GROUP_ID` | IDENT | guest / ended-guest Cloudron groups (L368, L378) |
| `MEMBER_BUDGET` | CONFIG | monthly member allowance in USD (L336, default 15.0) |
| `MANUAL_MEMBERS` | CONFIG | comma-separated members exempt from payment checks (L413) |
| `ALLOWANCE_POLICY` | CONFIG | allowance lapse policy: `report` (default) / `off` / `on` (L6514) |
| `ALLOWANCE_SHORTFALL_EMAILS` | CONFIG | shortfall mail flag `off`/`dryrun`/`on` (L7147) |
| `BUDGET_NOTICES` | CONFIG | budget-notice mail flag (L7748) |
| `DOCS_KNOWLEDGE_ID` | IDENT | docs-RAG knowledge-base id (L228, has default) |
| `LISTMONK_LIST_ID` | IDENT | "Members" list id (L491, default 3) |
| `LOOMIO_GROUP_ID` | IDENT | the co-op's Loomio group (L455) |
## 3. Read by code but UNSET (20) — behaviour comes from in-code defaults
These never appear in the container env; each has a default in `app/main.py`.
Documented so the defaults are discoverable (this closes the audit's
"undocumented env vars" gap). To change one, ADD it to the portal app env —
the code's `os.environ.get(name, default)` picks it up on restart.
`ADMIN_INVITER_EMAIL`, `ALLOWANCE_DEACTIVATE`, `BUDGET_NOTICE_AT`,
`CREDIT_PACK_URL`, `DB_PATH`, `GUEST_BUDGET`, `GUEST_DAYS`,
`GUEST_PER_INVITER_DAYS`, `LISTMONK_BASE`, `LOOMIO_ALWAYS_KEEP`,
`LOOMIO_BASE`, `LOOMIO_SYNC_ENABLED`, `MAIL_REPLY_TO`,
`MATRIX_EXTRA_MXIDS`, `MONEY_SERIES_TTL`, `OC_COLLECTIVE_SLUG`,
`OPERATOR_EMAILS`, `PAYMENT_GRACE_DAYS`, `PORTAL_BASE`, `REINVITE_AFTER_DAYS`.
## Maintenance rules
1. **No secret value belongs in any repo or doc.** This manifest intentionally
documents names, classes and *fingerprints at a point in time* — nothing else.
2. **Rotation order** (skill: never lock yourself out): prove the NEW credential
works against its owner service, then update the copy, then revoke the old.
3. **After any app restore**: fingerprint-diff every COPY row's owner side
against the portal copy and re-sync what differs (the 2026-11-05 playbook).
4. **De-duplication (flagged, deliberately not done 2026-11-05):** the
`LITELLM_DB_*` + `LITELLM_MASTER_KEY` copies exist because the portal reads
the ledger directly. The long-term fix — one source of truth, or a
gateway-side read-only aggregation endpoint — is recorded in the incident
doc and stays open until someone does it deliberately.