fix: remove passlib import from migration 0001, embed static hash
All checks were successful
Build containers when image tags change / build-if-image-changed (frontend, shorefront-frontend, shorefront frontend, frontend/Dockerfile, git.baumann.gr/adebaumann/shorefront-frontend, .frontend.image) (push) Successful in 30s
Build containers when image tags change / build-if-image-changed (backend, shorefront-backend, shorefront backend, backend/Dockerfile, git.baumann.gr/adebaumann/shorefront-backend, .backend.image) (push) Successful in 1m29s

This commit is contained in:
2026-03-01 01:08:40 +01:00
parent aaa6e7def4
commit 6b340f50cb
2 changed files with 6 additions and 4 deletions

View File

@@ -6,14 +6,16 @@ Create Date: 2026-02-28
""" """
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from passlib.context import CryptContext
revision = "0001" revision = "0001"
down_revision = None down_revision = None
branch_labels = None branch_labels = None
depends_on = None depends_on = None
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") # Pre-computed bcrypt hash of "admin". Used only for seeding the initial admin
# row; hashed_password becomes nullable in migration 0002 (SSO transition) and
# is never validated at login.
_ADMIN_HASH = "$2b$12$E8Td3Igd66V.udnDuflWFOhhhZDYFRHwLpgIsw.cRQtMf4h102sj."
def upgrade() -> None: def upgrade() -> None:
@@ -98,7 +100,7 @@ def upgrade() -> None:
"INSERT INTO users (username, email, hashed_password, is_active) " "INSERT INTO users (username, email, hashed_password, is_active) "
"VALUES (:u, :e, :p, true)" "VALUES (:u, :e, :p, true)"
), ),
{"u": "admin", "e": "admin@localhost", "p": pwd_context.hash("admin")}, {"u": "admin", "e": "admin@localhost", "p": _ADMIN_HASH},
) )
user_id = conn.execute(sa.text("SELECT id FROM users WHERE username='admin'")).scalar() user_id = conn.execute(sa.text("SELECT id FROM users WHERE username='admin'")).scalar()

View File

@@ -42,4 +42,4 @@ keycloak:
redirectUri: https://shorefront.baumann.gr/api/auth/oidc/callback redirectUri: https://shorefront.baumann.gr/api/auth/oidc/callback
containers: containers:
version: "0.004" version: "0.005"