feat(task-buttons): 跳转按钮可追加登录态 token+username + token 登录离线测试映射
rwfx/3qfx/xdfx 任务工作区的可配置跳转按钮(按钮管理)新增「追加登录态」开关: url 类型按钮可在外链后拼 ?token=<token1>&username=<登录名>(参数名可配,默认 token/username),供跳转目标外部系统识别当前登录用户。 - 仅 token 登录(login/token)生效: token1 = ?authToken=,username = 后端用 token 调 getTokenInfo 解析出的原始登录名(非邮箱前缀/非解 JWT)。二者登录时 经 persistLoginCredentials 存入 login.token1/login.username(scoped-storage 自动隔离嵌入/独立会话);非 token 登录读不到 token1 则跳过追加。 - 后端 UsernameLoginResponse 回传 username(原始名,规避邮箱归一化有损); token_login 加 mock_tokens 离线测试映射(123ewq->admin),命中即跳过外网 getTokenInfo,便于本地全链路联调。 - task_buttons 加列 append_auth/auth_token_param/auth_name_param (migration 20260625_01 + 幂等 SQL)。 Tests: test_task_buttons.py, test_auth_login_modes.py(mock token/username 回传)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6989dd45f1
commit
f8b40353ef
18 files changed
+298
-6
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
"""Add append_auth / auth_token_param / auth_name_param to task_buttons.
|
||||
|
||||
These back the「追加登录态」option on task-workspace jump buttons (按钮管理):
|
||||
a ``url`` button can append the login token (``token``) + username (``username``)
|
||||
to its external link so the target system can identify the current user.
|
||||
|
||||
Revision ID: 20260625_01
|
||||
Revises: 20260620_02
|
||||
Create Date: 2026-06-25
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import inspect
|
||||
|
||||
|
||||
revision = "20260625_01"
|
||||
down_revision = "20260620_02"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _has_table(table_name: str) -> bool:
|
||||
inspector = inspect(op.get_bind())
|
||||
return table_name in inspector.get_table_names()
|
||||
|
||||
|
||||
def _has_column(table_name: str, column_name: str) -> bool:
|
||||
if not _has_table(table_name):
|
||||
return False
|
||||
inspector = inspect(op.get_bind())
|
||||
return any(col["name"] == column_name for col in inspector.get_columns(table_name))
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ``task_buttons`` may not exist yet on a brand-new DB — create_all handles
|
||||
# that case with the columns already present, so only patch existing tables.
|
||||
if _has_table("task_buttons"):
|
||||
if not _has_column("task_buttons", "append_auth"):
|
||||
op.add_column(
|
||||
"task_buttons",
|
||||
sa.Column("append_auth", sa.Boolean(), nullable=False, server_default="0"),
|
||||
)
|
||||
if not _has_column("task_buttons", "auth_token_param"):
|
||||
op.add_column(
|
||||
"task_buttons",
|
||||
sa.Column("auth_token_param", sa.String(length=64), nullable=True, server_default="token"),
|
||||
)
|
||||
if not _has_column("task_buttons", "auth_name_param"):
|
||||
op.add_column(
|
||||
"task_buttons",
|
||||
sa.Column("auth_name_param", sa.String(length=64), nullable=True, server_default="username"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
for col in ("auth_name_param", "auth_token_param", "append_auth"):
|
||||
if _has_column("task_buttons", col):
|
||||
op.drop_column("task_buttons", col)
|
||||
Reference in new issue
Block a user