Skip to content

修复初始化注册密钥状态与并发问题(草稿) - #48

Open
atopos31 wants to merge 2 commits into
mainfrom
fix/registration-key-concurrency
Open

atopos31 wants to merge 2 commits into
mainfrom
fix/registration-key-concurrency

Conversation

@atopos31

@atopos31 atopos31 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

目标

本 PR 聚焦 CasaOS-UserService 初始化注册密钥的并发与状态问题。

对应安全问题:GHSA-hf9f-5qg4-r8gm。公告当前处于 triage,链接可能仅对有访问权限的协作者开放。

修改与对应问题

提交 修改 对应问题
981b2af 将普通注册密钥 map 改为 sync.Map。 避免普通 map 并发访问时发生竞态或崩溃。
a29c4a8 初始化期间复用唯一密钥;串行校验,在 SQLite 事务中确认尚无用户并创建首个管理员;成功后清空密钥。 防止初始化完成后复用旧密钥注册,并限制并发注册只能成功一次。后续实现以单密钥状态替代了前一提交的多密钥容器。

验证

  • 按仓库已有 go:generate 生成忽略的代码后,Linux/arm64 全包编译通过;生成文件未纳入提交。
  • go test -race ./service 通过:同一密钥重复获取、首次注册后失效、并发注册只创建一个用户。
  • 独立临时 Docker 容器中,64 次并发状态请求返回同一密钥;首次注册成功,再次使用旧密钥被拒绝;UserService 未重启。测试容器及临时数据已清理。

@atopos31 atopos31 changed the title 修复注册密钥并发访问(草稿) 修复初始化注册密钥状态与并发问题(草稿) Sep 28, 2026
@atopos31
atopos31 marked this pull request as ready for review September 28, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant