From 7a7c5e06e896c5a0273811a78ed49c59536af8e8 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Thu, 12 Nov 2026 10:21:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=85=8D=E7=BD=AE):=20=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=8F=A3=E4=BB=A4=E4=B8=89=E5=A4=84?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E5=88=B0=20admin@123=EF=BC=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=B8=8D=E5=86=8D=E6=8A=84=E7=AC=AC=E4=BA=8C=E9=81=8D?= =?UTF-8?q?=E5=8F=A3=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 播种用的初始口令在三个地方各写了一份:`.env.example`、`docker-compose.yml` 的 `BOOTSTRAP_PASSWORD` 默认值、`backend/app/config.py` 的 `bootstrap_password`, 三处原本都是 `admin1234`,而实际部署与本机库里跑的是 `admin@123`——默认值和真实 初始口令不一致,新库首启建出来的账号跟所有文档/脚本里那一对对不上。 `backend/tests/test_auth.py` 顺带把写死的 `ADMIN` 改成读 `settings.bootstrap_*`: 口令的权威只有 settings 一处,测试再抄一遍迟早对不上(这一条正是这次对不齐的成因)。 探针脚本里同样的口令默认值(8 只常驻探针)跟着改,走 `test(闸门)` 那个提交。 --- .env.example | 2 +- backend/app/config.py | 2 +- backend/tests/test_auth.py | 5 +++-- docker-compose.yml | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 8e54ef5..f25c9ab 100644 --- a/.env.example +++ b/.env.example @@ -22,7 +22,7 @@ INLINE_WORKERS=2 # ---------- 鉴权与账号 ---------- AUTH_ENABLED=true BOOTSTRAP_USERNAME=admin -BOOTSTRAP_PASSWORD=admin1234 # 库里首个管理员,登录后请立刻改口令 +BOOTSTRAP_PASSWORD=admin@123 # 库里首个管理员,登录后请立刻改口令 # ---------- 调度节奏 / 重试 / 断点续跑 ---------- DISPATCH_INTERVAL_SECONDS=5 diff --git a/backend/app/config.py b/backend/app/config.py index 52a8dec..797d8f3 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -74,7 +74,7 @@ class Settings(BaseSettings): password_iterations: int = 180_000 bootstrap_username: str = "admin" bootstrap_display_name: str = "平台管理员" - bootstrap_password: str = "admin1234" # 仅首次播种时使用,登录后强制改密 + bootstrap_password: str = "admin@123" # 仅首次播种时使用,登录后强制改密 # ---- 任务执行后端 ---- # celery = 生产模式(Redis broker + worker) diff --git a/backend/tests/test_auth.py b/backend/tests/test_auth.py index 97d564f..7258732 100644 --- a/backend/tests/test_auth.py +++ b/backend/tests/test_auth.py @@ -13,12 +13,13 @@ from app.db import SessionLocal from app.models import EventLog, User, UserSession from app.services import auth as auth_service -ADMIN = {"username": "admin", "password": "admin1234"} +# 口令不写死:播种用的是 settings.bootstrap_password,写死第二遍迟早对不上 +ADMIN = {"username": settings.bootstrap_username, "password": settings.bootstrap_password} @pytest.fixture def secured(client, monkeypatch): - """开启鉴权后的 TestClient(lifespan 已播种 admin/admin1234)。""" + """开启鉴权后的 TestClient(lifespan 已播种 settings 里那个初始管理员)。""" monkeypatch.setattr(settings, "auth_enabled", True) return client diff --git a/docker-compose.yml b/docker-compose.yml index 7ed5f38..8aea60d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: INLINE_WORKERS: "${INLINE_WORKERS:-2}" AUTH_ENABLED: "${AUTH_ENABLED:-true}" BOOTSTRAP_USERNAME: "${BOOTSTRAP_USERNAME:-admin}" - BOOTSTRAP_PASSWORD: "${BOOTSTRAP_PASSWORD:-admin1234}" + BOOTSTRAP_PASSWORD: "${BOOTSTRAP_PASSWORD:-admin@123}" AUTO_SEED: "${AUTO_SEED:-only-missing}" # 首启用 scripts/seed 灌模型配置:only-missing|force|off TZ: "${TZ:-Asia/Shanghai}" ports: