Skip to content

feat(ops): bootstrap_admin — the production first-admin path - #164

Merged
alovladi007 merged 1 commit into
mainfrom
feat/bootstrap-admin
Jul 30, 2026
Merged

feat(ops): bootstrap_admin — the production first-admin path#164
alovladi007 merged 1 commit into
mainfrom
feat/bootstrap-admin

Conversation

@alovladi007

Copy link
Copy Markdown
Owner

The deploy blocker this closes

seed_demo.py refuses production by design, which left a fresh production database with no way to create the first admin.

bootstrap_admin.py: creates org + first ADMIN; password via env/flag or generated-and-printed-once (nothing hardcoded, min 12 chars); refuses to run if the org already has any admin (exit 2, untouched DB); RLS-aware; baked into the analysis image:

docker compose run --rm analysis python bootstrap_admin.py --org "Acme Fab" --email admin@acme.example

Verified live

Bootstrap with generated password → real login 200 with the new credentials → second-admin attempt refused → cleanup. +3 unit tests; shared suite green.

🤖 Generated with Claude Code

seed_demo.py refuses ENVIRONMENT=production by design (it plants known
demo credentials), which left a fresh production database with NO way to
create the first admin. bootstrap_admin.py closes the gap:

- Creates the organization (or reuses it by name) + its first ADMIN user.
- Password from BOOTSTRAP_ADMIN_PASSWORD / --password, or a
  cryptographically random one generated and printed exactly once —
  nothing hardcoded, min length 12 enforced.
- Refuse-to-clobber: exits 2 without touching anything if the org already
  has ANY admin (bootstrap is for empty databases, not credential resets).
- RLS-aware (admin GUC, same convention as the seeds) and baked into the
  analysis image next to seed_demo.py:
      docker compose run --rm analysis python bootstrap_admin.py \
          --org "Acme Fab" --email admin@acme.example

Verified live against the compose database: bootstrap with a generated
password → real /api/auth/login 200 with the new credentials →
second-admin attempt REFUSED (exit 2) → test org removed. 3 new unit
tests (create, refusal, input validation) — shared suite green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alovladi007
alovladi007 merged commit 9f95474 into main Jul 30, 2026
17 checks passed
@alovladi007
alovladi007 deleted the feat/bootstrap-admin branch July 30, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant