feat(ops): bootstrap_admin — the production first-admin path - #164
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The deploy blocker this closes
seed_demo.pyrefuses 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: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