Skip to content

Comments

Add bootstrap admin team and user#40

Merged
yulmwu merged 7 commits intomainfrom
feat/bootstrap-admin
Feb 21, 2026
Merged

Add bootstrap admin team and user#40
yulmwu merged 7 commits intomainfrom
feat/bootstrap-admin

Conversation

@yulmwu
Copy link
Member

@yulmwu yulmwu commented Feb 21, 2026

At server startup, similar to database migration, the creation (bootstrapping) of an Admin team and an admin user has been added. This can be configured using the following options:

# Bootstrap
BOOTSTRAP_ADMIN_TEAM=true
BOOTSTRAP_ADMIN_USER=true
BOOTSTRAP_ADMIN_USERNAME=admin
BOOTSTRAP_ADMIN_EMAIL=
BOOTSTRAP_ADMIN_PASSWORD=

All values default to true. If BOOTSTRAP_ADMIN_EMAIL or BOOTSTRAP_ADMIN_PASSWORD is empty, the admin user will not be created, and only the Admin team will be created. The team name is fixed as Admin.

Additionally, the following configuration has been added to the dummy SQL generator script:

bootstrap:
  use_bootstrap_admin: true

Administrators are now placed exclusively in the Admin team. If the above options are enabled, the admin team and admin user will not be created again.

@yulmwu yulmwu requested a review from Copilot February 21, 2026 03:40
@yulmwu yulmwu self-assigned this Feb 21, 2026
@yulmwu yulmwu added the enhancement New feature or request label Feb 21, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds bootstrap functionality to automatically create an admin team and admin user at server startup when the database is empty. This feature allows for easier initial setup of CTF instances without requiring manual admin user creation through SQL scripts.

Changes:

  • Added bootstrap configuration options (BOOTSTRAP_ADMIN_TEAM, BOOTSTRAP_ADMIN_USER, BOOTSTRAP_ADMIN_USERNAME, BOOTSTRAP_ADMIN_EMAIL, BOOTSTRAP_ADMIN_PASSWORD) with defaults
  • Implemented bootstrap logic in Go to create Admin team and admin user on empty database
  • Updated dummy SQL generator to support bootstrap mode by commenting out admin team/user creation when enabled

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
cmd/server/bootstrap.go New file implementing bootstrap logic for admin team and user creation
cmd/server/main.go Integrates bootstrap function call at server startup
internal/config/config.go Adds BootstrapConfig struct and loading logic for bootstrap environment variables
internal/config/config_test.go Adds test coverage for bootstrap config redaction and logging
scripts/generate_dummy_sql/main.py Adds bootstrap mode support, adjusts user count calculations
scripts/generate_dummy_sql/generator.py Updates user and registration key generation to support bootstrap mode
scripts/generate_dummy_sql/sql_writer.py Adds logic to comment out admin team/user SQL in bootstrap mode
scripts/generate_dummy_sql/data_loader.py Fixes validation logic for user count
scripts/generate_dummy_sql/defaults/settings.yaml Adds bootstrap configuration with use_bootstrap_admin flag
scripts/generate_dummy_sql/defaults/data.yaml Unrelated change to stack_target_port
README.md Documents new bootstrap environment variables (with typo)
.env.example Adds bootstrap configuration examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

yulmwu and others added 6 commits February 21, 2026 12:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 74.44444% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/bootstrap/bootstrap.go 72.05% 12 Missing and 7 partials ⚠️
internal/config/config.go 81.81% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@yulmwu yulmwu merged commit 5c8ff6e into main Feb 21, 2026
2 checks passed
@yulmwu yulmwu deleted the feat/bootstrap-admin branch February 21, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant