Conversation
Contributor
There was a problem hiding this comment.
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.
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
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:
All values default to
true. IfBOOTSTRAP_ADMIN_EMAILorBOOTSTRAP_ADMIN_PASSWORDis empty, the admin user will not be created, and only the Admin team will be created. The team name is fixed asAdmin.Additionally, the following configuration has been added to the dummy SQL generator script:
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.