Skip to content

Auto-bootstrap admin from environment variables - #8

Merged
arantespp merged 2 commits into
mainfrom
copilot/create-env-vars-bootstrap-admin
Apr 16, 2026
Merged

Auto-bootstrap admin from environment variables#8
arantespp merged 2 commits into
mainfrom
copilot/create-env-vars-bootstrap-admin

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Currently the only way to create the first admin is to call POST /api/v1/users/bootstrap. This adds an automated path: if SOAT_ADMIN_USERNAME and SOAT_ADMIN_PASSWORD are set at startup and no users exist, the server creates the admin before accepting requests.

Changes

  • src/server.ts — after DB sync, reads SOAT_ADMIN_USERNAME / SOAT_ADMIN_PASSWORD and calls createFirstAdminUser. Reuses existing logic that no-ops when users already exist. Errors are caught and logged without crashing the server.
  • .env.example — documents the two new optional variables (commented out by default).
  • docs/modules/iam.md — extends the Bootstrap section with the env-var mechanism and an example snippet.

Usage

SOAT_ADMIN_USERNAME=admin
SOAT_ADMIN_PASSWORD=supersecret

On startup with an empty user table the server logs:

Admin user created from environment variables.

If users already exist the variables are silently ignored.

Copilot AI linked an issue Apr 16, 2026 that may be closed by this pull request
…SSWORD env vars

Agent-Logs-Url: https://github.com/ttoss/soat/sessions/4cd18efd-0b6c-44b1-8d3e-86e2d3e3aab1

Co-authored-by: arantespp <16626980+arantespp@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for creating admin using env vars Auto-bootstrap admin from environment variables Apr 16, 2026
Copilot AI requested a review from arantespp April 16, 2026 01:13
@arantespp
arantespp marked this pull request as ready for review April 16, 2026 01:15
@github-actions

Copy link
Copy Markdown

Deploy Outputs

Package Stack Output Key Output Value
@soat/website SoatWebsite-copilot-create-env-vars-bootstrap-admin BucketWebsiteURL http://soatwebsite-copilot-create-env-vars-b-staticbucket-sm4mk9epfsrn.s3-website-us-east-1.amazonaws.com

@arantespp
arantespp enabled auto-merge April 16, 2026 09:10
@arantespp
arantespp disabled auto-merge April 16, 2026 09:11
@arantespp
arantespp merged commit 0550dd7 into main Apr 16, 2026
3 checks passed
@arantespp
arantespp deleted the copilot/create-env-vars-bootstrap-admin branch April 16, 2026 09:11
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.

create env vars to bootstrap admin

2 participants