Skip to content

[P2][Security] 实现需要身份重验证的管理员第三方账号手动绑定流程 #64

Description

@fxbin

背景

PR #62(main @ 7203847)已加固 get_or_create_oauth_user:

  • 未验证 OAuth 身份一律拒绝创建/登录;
  • 已验证邮箱只能自动关联「活跃的非管理员」账号;
  • 管理员账号的既有绑定仍可用,但新绑定被显式禁止(此账号不支持自动关联,请使用原有登录方式);
  • service docstring 明确写着 "Admin accounts require an explicit authenticated linking flow (not provided by this function)"。

缺口

当前 OAuth API 没有提供该「显式已认证绑定流程」:已登录用户(含管理员)无法在保持会话 + 重新验证身份的前提下,把自己的 Google/GitHub 身份安全挂到现有账号上。结果是管理员永远无法使用第三方登录,普通用户更换第三方身份也只能走自动合并的窄路径。

建议方案

新增需要双重验证的绑定端点(挂 auth 域):

  1. 用户以密码会话登录后,进入设置页发起「绑定第三方账号」;
  2. 要求重新输入密码(或等效的 step-up 验证)确认本人操作;
  3. 后端携带 state 发起 OAuth,回调时校验「发起绑定的会话本人」与「新 OAuth 身份 email 已验证」后写入 user_oauth_account;
  4. 明确拒绝目标账号已有同 provider 绑定的场景(先解绑再绑,防置换攻击)。

验收标准

关联

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions