Repository navigation
让鼠钟等自家应用用鼠洞账号登录 - #347
Merged
Merged
让鼠钟等自家应用用鼠洞账号登录#347
Conversation
鼠钟一期要用鼠洞账号登录(总体设计 §6.7,接口 §8.3)。这是路线图第 3 步 OAuth 里自家应用的一半;元数据、Agent 注册和 Agent 的授权页之后和 MCP 一起做。 - 新表 oauth_clients、oauth_codes,api_tokens 加上 client_id - 后台的「应用」页和 /admin/apps 接口:登记、修改、换密钥、停用,停用时它的令牌都作废 - /oauth/authorize 页:登录了的直接带着授权码、state 和 iss 跳回;没登录的带 prompt=none 时带着 login_required 跳回,否则先去登录页,用口令或 QQ 邮箱登录后回到这里 - POST /oauth/token:PKCE(S256)加密钥换令牌,密钥放在 Basic 认证里或表单里;授权码 5 分钟有效,试一次就没了;每人在每个应用只有一个令牌 - 封禁时没换的授权码也删掉,过期的每天清理 - GET /me 加上 restriction
This was referenced Nov 6, 2026
JunieXD
added a commit
to mousebaoyan/mouseclock
that referenced
this pull request
Nov 6, 2026
鼠洞在 mousebaoyan/mousehole#347 实现了自家应用的 OAuth,鼠钟的登录不用改就能对上,文档里「还没实现」的说法去掉。 - 总体设计 §6.1、§17 去掉还没实现的说法,§18 待定事项删掉授权接口 - 开发约定写上怎么对着本地的鼠洞登录:鼠洞的开发版占着 5173,鼠钟换到 5174
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.
Refs #336
鼠钟一期要用鼠洞账号登录(总体设计 §6.7,接口 §8.3)。这是路线图第 3 步 OAuth 里自家应用的一半,建在 #346 成员的令牌上。授权服务器的元数据、Agent 注册、Agent 的授权页和设置页的接入命令,之后和 MCP 一起做:鼠钟用固定的地址就能连上,用不到它们。
改了什么
oauth_clients(自家应用,只存密钥的 SHA-256)、oauth_codes(授权码,只存 SHA-256),api_tokens加上client_id/admin/apps的四个,停用时它的令牌都标为撤销/oauth/authorize页:自家应用不显示授权页code、state和iss跳回prompt=none时带着error=login_required跳回,否则去/login?next=…,用口令或 QQ 邮箱登录后回到授权页(链接登录在手机 QQ 里打开,回不到原来的浏览器)POST /api/v1/oauth/authorize,只能在网页上调POST /oauth/token:用授权码、PKCE(S256)和密钥换令牌,密钥放在 Basic 认证里或表单里;返回和错误按 OAuth 的格式,带Cache-Control: no-store。它在 CSRF 检查之前:应用的服务端调用时不带 Origin,靠密钥认DELETE … RETURNING里取出,对不上也用掉了;封禁时删掉这个人没换的码,过期的每天清理GET /me加上restriction,鼠钟每小时用它刷新禁言状态怎么验证的
pnpm check通过:类型检查、lint、格式和 412 个测试。新加的server/modules/auth/oauth.test.ts有 8 个:/me和禁言状态prompt=none带着login_required跳回,不带返回401pnpm e2e通过,新加一个流程:站长在后台登记应用;登录了的打开授权页带着授权码回去;访客带prompt=none带着login_required回去,不带时去登录页pnpm mock-bot code确认,回到授权页,带着授权码跳回;再用client_secret_post换到令牌,用它取到/mepnpm phone-check看过/admin/apps、它的修改状态和授权页的报错,没有超出屏幕的元素影响
next,只接受本站的路径client_id和密钥填进鼠钟的MOUSEHOLE_CLIENT_ID、MOUSEHOLE_CLIENT_SECRET