Skip to content

feat: auto-seed admin + healthcheck fix (from PR #41, security hardened)#42

Merged
garfieldstoun merged 1 commit intomainfrom
daedalus/seed-admin-healthcheck
Mar 25, 2026
Merged

feat: auto-seed admin + healthcheck fix (from PR #41, security hardened)#42
garfieldstoun merged 1 commit intomainfrom
daedalus/seed-admin-healthcheck

Conversation

@howard-eridani
Copy link
Copy Markdown
Contributor

Summary

Based on community contribution from @venturecrew / @appset in #41, with security fixes:

  • Auto-seed admin user when MESH_SEED_ADMIN=true and no users exist in DB. Configurable via MESH_ADMIN_EMAIL, MESH_ADMIN_PASSWORD, MESH_ADMIN_NAME env vars
  • Healthcheck fix: wget --spiderwget -O /dev/null (our /health endpoint returns 405 for HEAD)
  • Quickstart docs updated to mention seed admin option

Security fixes vs original PR #41

Issue PR #41 This PR
Password logged to stdout log.Printf("...%s / %s", email, pass) Only logs email, never password
Default in prod compose MESH_SEED_ADMIN:-true (always seeds) MESH_SEED_ADMIN:-false (opt-in)
Default password empty Falls back to Admin123 Same fallback, but not logged

Closes #41

Test plan

  • go build ./cmd/api — compiles
  • All tests pass (pre-push hook)
  • Manual: start with MESH_SEED_ADMIN=true on empty DB — admin created
  • Manual: start without flag — no seed
  • Manual: docker compose healthcheck passes

🤖 Generated with Claude Code

@garfieldstoun
Copy link
Copy Markdown
Contributor

Hey @daedalus-mb, two things to address before this can merge:

1. Lint failure (govet shadow)

cmd/api/main.go:95:6: shadow: declaration of "err" shadows declaration at line 38 (govet)
    if err := db.QueryRow("SELECT COUNT(*) FROM users").Scan(&count); err == nil && count == 0 {

The inner err in the seed block shadows the outer err from line 38. Fix: rename it to seedErr (or any other non-conflicting name).

2. Merge conflict
PR #43 (docker-deploy restructure) was just merged into main. This branch now has a conflict — please rebase onto main before re-pushing.

Steps:

git fetch origin
git rebase origin/main
# fix the shadow var
git push --force-with-lease

Once lint is green and the conflict is resolved, this is good to go.

Cherry-pick community contribution from venturecrew/appset with security fixes:
- Auto-seed admin when MESH_SEED_ADMIN=true and no users exist
- SECURITY: never log passwords (only email), default MESH_SEED_ADMIN=false in prod
- Fix Docker healthcheck: use GET (-O /dev/null) instead of HEAD (--spider)
- Update quickstart.md to mention seed admin option

Based on: #41

Co-Authored-By: appset <appset@users.noreply.github.com>
Co-Authored-By: Venture Crew <venturecrew@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@daedalus-mb daedalus-mb force-pushed the daedalus/seed-admin-healthcheck branch from bc24ddb to 344a766 Compare March 25, 2026 16:12
Copy link
Copy Markdown
Contributor

@garfieldstoun garfieldstoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. govet shadow fixed (seedErr/regErr), password leak removed from logs. CI green. Merging.

@garfieldstoun garfieldstoun merged commit ccdf0bc into main Mar 25, 2026
3 checks passed
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.

3 participants