feat(auth): 登录白名单细化为黑名单模式(approved 默认放行)+ 同步构建产物
- approved 放行标记默认 True:新账号首次登录即放行,登录白名单开关打开时只拦截 被管理员显式「取消放行」(approved=False) 的用户;enforce_user_approved 放在 各登录端点拿到 user 后、签发 JWT 前调用,admin 永远放行。 - 同步调整 LoginWhitelistPage / local_provider / models / system_settings / 迁移 20260625_02 / user model / column_additions_mysql.sql 与 CLAUDE.md。 - 更新 backend/backend.zip 构建产物。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f3f11461de
commit
a417124c21
9 files changed
+47
-39
No files matched your search
+5
-3
@@ -1,8 +1,10 @@
|
||||
"""Add users.approved (登录白名单放行标记).
|
||||
|
||||
Backs the login-whitelist feature: when system setting ``login_whitelist.enabled``
|
||||
is on, only ``approved=True`` users (or admins) may log in; self-registered
|
||||
regular users default to ``approved=False`` (待审批) until an admin approves them.
|
||||
Backs the login-whitelist feature (黑名单模式): when system setting
|
||||
``login_whitelist.enabled`` is on, only users an admin has explicitly
|
||||
「取消放行」 (``approved=False``) are blocked; everyone else — including brand-new
|
||||
accounts that have never logged in (which default to ``approved=True``) — may log
|
||||
in. Admins always pass.
|
||||
|
||||
Existing rows are backfilled to TRUE (``server_default="1"``) so flipping the
|
||||
switch on for the first time never locks out users who already had accounts.
|
||||
|
||||
+6
-6
@@ -49,12 +49,12 @@ class UserRow(Base):
|
||||
needs_setup: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
token_version: Mapped[int] = mapped_column(nullable=False, default=0)
|
||||
|
||||
# 登录白名单(放行)标记。仅当系统设置 ``login_whitelist.enabled`` 打开时生效:
|
||||
# 关 → 忽略此列,人人可登录;开 → 仅 approved=True(或 admin)可登录,其余
|
||||
# 注册后处于「待审批」直到管理员放行。新注册的普通用户默认 False(待审批),
|
||||
# admin 创建即 True;存量用户由迁移回填 True(避免首次打开开关时把老用户锁死)。
|
||||
# server_default=1 让迁移 ADD COLUMN 时把已存在行置为已放行。
|
||||
approved: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("1"))
|
||||
# 登录白名单(放行)标记 —— **黑名单模式**。仅当系统设置 ``login_whitelist.enabled``
|
||||
# 打开时生效:关 → 忽略此列,人人可登录;开 → 仅 approved=False(被管理员显式
|
||||
# 「取消放行」)的用户被拦,其余(含从未登录过的新账号)放行。新账号默认 True
|
||||
# (首次登录即放行);存量用户由迁移回填 True。server_default=1 让迁移 ADD COLUMN
|
||||
# 时把已存在行置为已放行。
|
||||
approved: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, server_default=text("1"))
|
||||
|
||||
# 岗位 (position) the user is assigned to (1:1). NULL = no explicit
|
||||
# position → the user inherits the ``is_default`` position's grants. Drives
|
||||
|
||||
Reference in new issue
Block a user