bug(user): admin seed ignores APP_ADMIN_USERNAME / PASSWORD — falls back to defaults (HIGH, prod-blocking) #513
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
UserDataInitializerandapplication.yamluse different property keys. The Java code readsapp.admin.email, but the yaml maps the env var toapp.admin.username. They never connect — the env varsAPP_ADMIN_USERNAMEandAPP_ADMIN_PASSWORDare silently ignored, and the admin user is always seeded with the hardcoded defaultsadmin@familyarchive.local/admin123.Evidence (from running staging stack)
Env vars correctly set in the container; the seeded admin uses defaults anyway.
Code
Impact
admin@familyarchive.local/admin123— the dev defaults. An operator who setsPROD_APP_ADMIN_PASSWORDto a strong value in Gitea secrets gets a false sense of security; the actual admin credentials are the same dev defaults shipped in the repo.admin@familyarchive.local/admin123(so login works — just not with the intended credentials).Fix
Rename the yaml key from
username:toemail:so the Spring propertyapp.admin.emailactually exists. Keep env var nameAPP_ADMIN_USERNAME(Gitea secrets already use it). Also fix the default to be an email-shape:Alternative considered: change
UserDataInitializer.javato read${app.admin.username:...}. Rejected because the domain field isemail, notusername— the yaml key was the source of confusion.After-merge cleanup for staging
The existing
admin@familyarchive.localuser in the staging DB will persist (UserDataInitializer only seeds if missing). Options:admin@familyarchive.local/admin123.archiv-staging_postgres-dataand re-deploy to get a fresh seed.For production: the bug must land before
v1.0.0, otherwise we permanently lock the prod admin password toadmin123.Discovered
While trying to log into staging with the credentials we set in Gitea secrets via the bootstrap procedure for #497.