Repository navigation
fix(auth): 第三方建的无密码账号能设上密码 · 菜单 perms 切分统一(#402) - #431
Merged
Merged
Conversation
yile2020
force-pushed
the
fix/issue-402
branch
2 times, most recently
from
November 21, 2026 22:41
bc17cda to
ac16886
Compare
yile2020
enabled auto-merge
November 21, 2026 23:04
This was referenced Nov 21, 2026
- 超管重置 / 自助改密不再在 password=None 的密码历史上抛 ValidationError - 无密码账号第一次设密码:不验旧密码,改验重新走一遍已绑定第三方授权留下的一次性凭据 (GET /oauth2/me/reauth → 回调按 sid 核对绑定归属 → 10 分钟、GETDEL 消费); 只拿着一个会话设不了 - 新增 GET /sys/users/me/password-status;个人中心「设置密码」两步引导 + 文案 - 无密码账号不能解绑最后一个第三方账号;绑定 / 重新验证回调落个人中心「安全」页 - 菜单 perms 统一走 common/security/perms.py: split_perms(去空格去空段), rbac_verify / get_codes / 文件关联 / 审批 / AI 工具一致;写入时 schema 规范化 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 无密码账号的设密凭据改记在发起重新授权的那个会话上(state 带 session_uuid,key 带会话), 另一个会话(偷来的 token)不能抢先用掉本人刚完成的验证 - 解绑第三方账号先 FOR UPDATE 锁用户行再数(SQL Server 加 UPDLOCK, HOLDLOCK), 并发解绑两个来源不再把无密码账号清空 - 已有密码的账号不发重新验证链接 - 前端:改 / 设密码成功后不再作废密码状态查询(会话已撤,重取 401 会立刻踢人、倒计时消失); 提交失败时重取状态,凭据过期就退回「先验证身份」 - 测试:pytest 新增 3 条、E2E 新增 2 条,均在修复前红 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yile2020
force-pushed
the
fix/issue-402
branch
from
November 21, 2026 23:29
ac16886 to
7efbd65
Compare
yile2020
added a commit
that referenced
this pull request
Nov 22, 2026
…回落默认源(#437) - 无密码账号第一次设密码:凭据不再在写库前 GETDEL。另一把 key 上 SET NX 占位(并发只有一个拿得到), 写库抛错同步放开占位、提交失败由会话最外层回滚钩子放开,提交成功后后台任务删凭据 - profile_security_url 用 urlsplit / parse_qsl 设 section,已带 section= 或 # 时不再落错面板 - 桌面端:主进程记下已下载的版本、新 IPC updater:downloaded;quitAndInstall 拿不到更新器时抛错; 渲染层根上挂 DesktopUpdatePrompt,下载好后弹不自动消失的「重启更新」,失败报错可重试(中英文案) - 运行中把 updateUrl 清空:autoUpdater.updateConfigPath = null,下次检查重读 app-update.yml - 分支合入了 origin/main(#435 的桌面端改动),本 PR 依赖 #431 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yile2020
added a commit
that referenced
this pull request
Nov 22, 2026
…回落默认源(#437) - 无密码账号第一次设密码:凭据不再在写库前 GETDEL。另一把 key 上 SET NX 占位(并发只有一个拿得到), 写库抛错同步放开占位、提交失败由会话最外层回滚钩子放开,提交成功后后台任务删凭据 - profile_security_url 用 urlsplit / parse_qsl 设 section,已带 section= 或 # 时不再落错面板 - 桌面端:主进程记下已下载的版本、新 IPC updater:downloaded;quitAndInstall 拿不到更新器时抛错; 渲染层根上挂 DesktopUpdatePrompt,下载好后弹不自动消失的「重启更新」,失败报错可重试(中英文案) - 运行中把 updateUrl 清空:autoUpdater.updateConfigPath = null,下次检查重读 app-update.yml - 分支合入了 origin/main(#435 的桌面端改动),本 PR 依赖 #431 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #402
1. 无密码账号(第三方登录建的)设不上密码
原因:
user_service的超管重置和自助改密都在改完之后写密码历史CreateUserPasswordHistoryParam(password=None),必填str→ ValidationError(超管那条前端看到的是 422「password 输入应为有效的字符串,输入:None」)。自助那条同时跳过了旧密码校验,一直是这个异常在兜底。修法:
app/admin/utils/password_set_grant.py)。凭据只能由重新走一遍已绑定的第三方授权产生:GET /oauth2/me/reauth?source=→ 一次性 ticket + state cookie(照抄绑定流程)→ 回调按sid查绑定、核对属于发起人才写入,10 分钟;update_password在复杂度等校验通过后才GETDEL消费。只拿着一个会话(比如被盗的 access token)设不了GET /sys/users/me/password-status(has_password/reauth_verified);ResetPasswordParam.old_password改为可选个人中心?section=security(原来落「资料」面板)plugin/oauth2/AGENTS.md。私有公告里另外两条(改密接口限流、bcrypt 进线程池)不在本 PR 范围。2. 菜单
perms切分不一致抽出
common/security/perms.py: split_perms(去空格、去空段,单独零依赖模块避免schema → rbac → jwt → schema循环导入),rbac_verify(改为直接用collect_allowed_perms)/get_codes两支 /file_service._has_perm/ 审批Actor.from_user/ AI 菜单工具统一使用;MenuWriteParam写入时规范化成"a,b",只剩逗号空格的存 None(按钮照样被拒)。测试
plugin/oauth2/tests/test_passwordless_set_password.py9 条(修前 7 条红)、app/admin/tests/security/test_perms_split.py12 条(修前 9 条红);变异检验各自打红,记录在两份 AGENTS.mdprofile-first-password.spec.ts4 条(page.route改写状态),连同login/profile-phone共 7 条通过;变异「恒画修改密码」4 条全红pnpm typecheck --force·lint·arch:check·i18n:check·ctx:check全过;gen:api已重新生成test_opera_log_redaction白名单补了has_password(布尔,不是凭据)没验证
🤖 Generated with Claude Code