AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
fix: harden env plumbing per security review
Claude0738592af792
diff --git a/Makefile b/Makefileindex 678ec80b..0ed162bc 100644--- a/Makefile+++ b/Makefile@@ -4,12 +4,17 @@ install:cd packages/core && uv synccd packages/ui && npm install+# Both dev recipe lines source the repo-root .env into the process env:+# - the UI needs it because Next.js only auto-loads packages/ui/.env*, so+# Auth.js never saw AUTH_SECRET etc. (issue #44);+# - the API needs it because BACKEND_SHARED_SECRET / BACKEND_ALLOWED_ORIGINS+# are read from os.environ, not pydantic Settings — dotenv alone doesn't+# surface them, silently leaving the API gate open.+# Note: exported values win over packages/ui/.env.local for duplicate keys.+# .env values must be shell-safe: quote anything containing spaces or `$`.dev:@echo "Starting Open Executive..."- @cd packages/core && uv run uvicorn openexecutive.api.main:app --reload --port 8000 &- @# Export the repo-root .env into the UI process: Next.js only auto-loads- @# packages/ui/.env*, so without this Auth.js never sees AUTH_SECRET etc.- @# (issue #44). packages/ui/.env.local still works and takes precedence.+ @if [ -f .env ]; then set -a; . ./.env; set +a; fi; cd packages/core && uv run uvicorn openexecutive.api.main:app --reload --port 8000 &@if [ -f .env ]; then set -a; . ./.env; set +a; fi; cd packages/ui && npm run devstop:diff --git a/README.md b/README.mdindex 1a8876c0..32bb020c 100644--- a/README.md+++ b/README.md@@ -118,7 +118,8 @@ make devAll configuration lives in that repo-root `.env` — `make dev` and `make docker`both load it for the API *and* the UI (Auth.js needs `AUTH_SECRET` /`AUTH_GOOGLE_ID` / `AUTH_GOOGLE_SECRET` at runtime). A-`packages/ui/.env.local` is also supported and overrides the root file.+`packages/ui/.env.local` is also read for UI-only keys, but for keys present+in both files the root `.env` takes precedence.Open http://localhost:3000 to start chatting with your executive. The API runs on port 8000 and the UI on 3000.diff --git a/docker/docker-compose.yml b/docker/docker-compose.ymlindex 728b4608..adf8563a 100644--- a/docker/docker-compose.yml+++ b/docker/docker-compose.yml@@ -4,28 +4,21 @@ services:context: ..dockerfile: docker/Dockerfile# Load the full repo-root .env (the file README's quickstart has you- # create) into the container: model providers, integrations, auth, etc.- # `required: false` keeps shell-export-only setups working without one.+ # create) into the API container: model providers, integrations, auth,+ # etc. `required: false` tolerates setups that export vars in the shell+ # and run `make docker` (the Makefile passes --env-file so ${VAR}+ # interpolation sees them) without a .env file.# NOTE: anything listed under `environment:` below SHADOWS the same key- # from this env_file — don't add a key in both places.+ # from this env_file — keep that list to container-specific fixed paths.env_file:- path: ../.envrequired: falseports:- "8000:8000"environment:- # ${VAR} interpolation resolves from the shell, or from the repo-root- # .env when invoked as `make docker` (the Makefile passes --env-file).- - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}- VECTOR_STORE_PATH=/data/chroma_db- COMPANY_PROFILE_PATH=/data/company/profile.yaml- EPISODIC_DB_PATH=/data/episodic_memory.db- - ENABLE_CACHING=${ENABLE_CACHING:-true}- - SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN:-}- - SLACK_APP_TOKEN=${SLACK_APP_TOKEN:-}- # Outbound email goes through the Gmail Workspace MCP authenticated as- # this address (see .env.example / docs). Leave blank to disable email.- - EXEC_EMAIL_ADDRESS=${EXEC_EMAIL_ADDRESS:-}volumes:- executive_data:/datahealthcheck:@@ -38,24 +31,30 @@ services:image: node:22-alpineworking_dir: /appcommand: sh -c "npm install && npm run dev"- # Auth.js reads AUTH_SECRET / AUTH_GOOGLE_ID / AUTH_GOOGLE_SECRET (and- # ALLOWED_EMAILS, BACKEND_SHARED_SECRET, ...) from process.env — without- # this env_file the sign-in flow fails with [auth] MissingSecret because- # the root .env never reached the UI container (issue #44).- env_file:- - path: ../.env- required: falseports:- "3000:3000"volumes:- ../packages/ui:/app- /app/node_modules+ # Deliberately NO env_file here: this container runs `npm install` at+ # boot, and npm postinstall scripts can read process.env — so the UI+ # gets only the variables it actually uses, not the backend's provider+ # keys and bot tokens. ${VAR:-} resolves from the repo-root .env when+ # invoked as `make docker` (the Makefile passes --env-file .env), or+ # from exported shell variables. Auth.js needs the AUTH_* set at+ # runtime — without them sign-in fails with MissingSecret (issue #44).environment:- NODE_ENV=development# Reach the API over the compose network (the UI proxy/auth default of# localhost:8000 resolves to the UI container itself, not the API).- # Deliberately overrides any BACKEND_BASE_URL from the root .env.- BACKEND_BASE_URL=http://api:8000+ - AUTH_SECRET=${AUTH_SECRET:-}+ - AUTH_GOOGLE_ID=${AUTH_GOOGLE_ID:-}+ - AUTH_GOOGLE_SECRET=${AUTH_GOOGLE_SECRET:-}+ - AUTH_TRUST_HOST=${AUTH_TRUST_HOST:-true}+ - AUTH_URL=${AUTH_URL:-}+ - ALLOWED_EMAILS=${ALLOWED_EMAILS:-}+ - BACKEND_SHARED_SECRET=${BACKEND_SHARED_SECRET:-}depends_on:- apidiff --git a/docs/auth.md b/docs/auth.mdindex 805537a2..ae14daee 100644--- a/docs/auth.md+++ b/docs/auth.md@@ -59,24 +59,36 @@ Put everything in the repo-root `.env` (the file the README quickstart has youcreate from `.env.example`). Both `make dev` and `make docker` load it into theAPI **and** the UI:+Generate the two random secrets first and paste their **output** — never put+`$(...)` inside the file itself: the file is parsed as plain text by Docker+Compose and the backend's dotenv loader, so command substitutions become the+literal (publicly known) string instead of a secret.++```bash+openssl rand -base64 32 # → paste as AUTH_SECRET+openssl rand -hex 32 # → paste as BACKEND_SHARED_SECRET+```+```bashAUTH_GOOGLE_ID=<from google>AUTH_GOOGLE_SECRET=<from google>-AUTH_SECRET=$(openssl rand -base64 32)+AUTH_SECRET=<paste the base64 output>AUTH_TRUST_HOST=true# AUTH_URL stays blank for local dev — set it only on public deployments.-BACKEND_SHARED_SECRET=$(openssl rand -hex 32)+BACKEND_SHARED_SECRET=<paste the hex output>ANTHROPIC_API_KEY=sk-ant-...```Then `make dev` and visit http://localhost:3000.-A `packages/ui/.env.local` (also gitignored) still works and **overrides** the-root `.env` for the UI — useful if you want UI-only overrides such as-`BACKEND_BASE_URL=http://localhost:8000`. Note that plain `npm run dev` in-`packages/ui` (without `make dev`) only reads `packages/ui/.env*`, not the-root `.env`.+A `packages/ui/.env.local` (also gitignored) still works, but note the+precedence: under `make dev` / `make docker` the root `.env` is exported into+the process environment before Next.js starts, and Next never overrides an+already-set variable — so **for any key present in both files, the root `.env`+wins**. Use `.env.local` only for UI-only keys that aren't in the root file.+Plain `npm run dev` in `packages/ui` (without `make dev`) reads only+`packages/ui/.env*`, not the root `.env`.### Production (Fly secrets)@@ -143,7 +155,7 @@ flyctl secrets set -a openexec-ui-dev AUTH_SECRET="$(openssl rand -base64 32)"### Revoke OAuth client-If `AUTH_GOOGLE_SECRET` is leaked, regenerate in Google Cloud Console (Clients → your client → **Reset Secret**), then update both your local `.env.local` and the Fly secret. Old issued tokens stop working immediately.+If `AUTH_GOOGLE_SECRET` is leaked, regenerate in Google Cloud Console (Clients → your client → **Reset Secret**), then update both your local root `.env` (and `packages/ui/.env.local` if you use one) and the Fly secret. Old issued tokens stop working immediately.---