[Bug] - Accounts deleted after container restart, pegaprox password reverts to 'admin'
Describe the bug
_migrate_from_legacy() in db.py wipes all users and resets the pegaprox account to the default admin password on every container restart when any OIDC/Entra ID/LDAP user exists in the database.
The root cause is a startup check that looks for any user with an empty password_salt.
External auth users (OIDC, Entra ID, LDAP) legitimately have no password_salt — their authentication is handled externally.
When such a user is the first row returned, the check incorrectly sets needs_user_remigration = True, which then:
- Runs
DELETE FROM users— wipes the entire users table - Attempts to re-migrate from
users.enc(legacy encrypted file) — which doesn't exist on SQLite-based installs - Falls through to
create_default_users()— recreatespegaproxwithpassword=adminandforce_password_change=True
Relevant code in pegaprox/core/db.py inside _migrate_from_legacy():
cursor.execute("SELECT username, password_salt FROM users LIMIT 1")
row = cursor.fetchone()
if row:
salt = row[1] if len(row) > 1 else None
if not salt or salt == '': # <-- fires on every OIDC/Entra user
needs_user_remigration = True
Steps to Reproduce
- Configure Entra ID / OIDC / LDAP authentication in PegaProx settings
- Log in with an external auth user — the account is saved to the SQLite DB with an empty
password_salt - Restart the container (
docker compose restart) - All users are gone; the
pegaproxaccount is back withpassword=adminandforce_password_change=1
Expected behavior
Container restarts should not affect user accounts. External auth users have no password_salt by design and should never trigger legacy migration. All existing users should persist across restarts.
Suggested fix — scope the check to local auth users only:
# Before:
cursor.execute("SELECT username, password_salt FROM users LIMIT 1")
# After:
cursor.execute("SELECT username, password_salt FROM users WHERE auth_source = 'local' LIMIT 1")
Environment
- PegaProx Version: 0.9.3 Beta
- Installation Method: Docker
- OS: Debian 12
- Browser: N/A (API-level reproduction)
- Behind Reverse Proxy? No
- UI? Modern Layout
Logs
# On startup (docker logs pegaprox):
Initializing user system...
Loaded 2 users # <-- users loaded correctly from DB
# But after restart, users are gone and this appears:
DEFAULT LOGIN CREDENTIALS:
Username: pegaprox
Password: admin
Please change the password after first login!
# DB state before restart — confirms empty salt for Entra ID user:
# SELECT username, password_salt FROM users;
# yair.mizrahi | '' <-- Entra ID user, empty salt
# pegaprox | 'argon2' <-- local user, has salt
Just did shoot trough the fix :)
Thanks for reporting!
Best Regards, Nico