双份cookie存储:raw_cookie 保存App原始凭据,与网页运行ck分离
网页运行ck(cookie列)含本地随机生成的网页设备字段,若被风控标记 无法还原纯净登录凭据;新增 raw_cookie 保存16字段App原始态,供 设备态重建/审计/复核登录有效性。 - HuyaAccount 加 raw_cookie 列(alembic 0034,MySQL TEXT nullable) - HuyaLoginResult 加 raw_cookie 字段;App登录链补齐前快照原始凭据 - upsert_huya_cookie 支持双写;app-password-login 路由透传 raw_cookie - 存量行 raw_cookie 为 NULL(老账号无快照),新登录自动填充
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""huya_accounts 增加 raw_cookie:保存 App 登录原始凭据(与网页运行 ck 分离)。
|
||||
|
||||
网页运行 ck(cookie 列)含本地随机生成的网页设备字段(guid/_qimei_uuid42/
|
||||
__yamid_new/game_did),若设备字段被风控标记无法还原纯净的登录凭据。
|
||||
raw_cookie 保存 16 字段的原始 App 登录态(udb_* 认证 + sdid/hdid + 匿名设备
|
||||
字段),用于重建设备态/审计/复核登录有效性。
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20260901_0034"
|
||||
down_revision: str | None = "20260901_0033"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
columns = {
|
||||
item["name"] for item in sa.inspect(bind).get_columns("huya_accounts")
|
||||
}
|
||||
if "raw_cookie" not in columns:
|
||||
# MySQL 的 TEXT 列不允许 server_default;模型层 default="" 负责新行,
|
||||
# 存量行为 NULL(读取处按空处理)。
|
||||
op.add_column(
|
||||
"huya_accounts",
|
||||
sa.Column("raw_cookie", sa.Text(), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
columns = {
|
||||
item["name"] for item in sa.inspect(bind).get_columns("huya_accounts")
|
||||
}
|
||||
if "raw_cookie" in columns:
|
||||
op.drop_column("huya_accounts", "raw_cookie")
|
||||
Reference in New Issue
Block a user