Skip to content

fix(oauth): 客户端元数据文档只在精确地址提供,缓存 5 分钟 - #87

Merged
yi-ge merged 1 commit into
mainfrom
fix/oauth-client-metadata-exact-url
Nov 27, 2026
Merged

yi-ge merged 1 commit into
mainfrom
fix/oauth-client-metadata-exact-url

Conversation

@yi-ge

@yi-ge yi-ge commented Nov 27, 2026

Copy link
Copy Markdown
Member

变更说明 / Description

/oauth/clients/desirecore-desktop-v1.json 是 DesireCore 桌面端的 MCP OAuth 客户端元数据文档(CIMD):文档的 URL 本身就是公开的 client_id,授权服务器按这个精确地址读取(desirecore/desirecore#5724、ADR-341)。本 PR 只处理站点上这条路径,不改文档内容、不改其他页面。

  • 缓存头:/oauth/clients/:file 的 Cache-Control 由 Vercel 默认的 public, max-age=0, must-revalidate 改为 public, max-age=300(vercel.json 的 headers)。
  • 末尾斜杠:/oauth/clients/<文件>/ 现在 308 到不带斜杠的精确地址,不再直接返回 200 文档(vercel.json 的 redirects,只匹配这一层路径,不影响站点其他 URL 的斜杠行为)。
  • /en/ 副本:Docusaurus 构建每个非默认语言时会把 static/ 原样复制进 build/<locale>/,所以 /en/oauth/clients/... 也返回同一份文档。新增 plugins/oauth-client-metadata-plugin.ts,只在非默认语言的 postBuild 删除输出目录里的 oauth/(路径断言在输出目录内),这些地址改为 404。

The CIMD document URL is the public client_id, so aliases are not identities. This PR sets Cache-Control: public, max-age=300 for /oauth/clients/:file, 308-redirects the trailing-slash variant to the exact URL, and removes the oauth/ copy that Docusaurus places into non-default locale builds so /en/oauth/clients/... returns 404. Document content is unchanged.

测试方式 / Test Plan

  • 用本仓库 node_modules 的 Docusaurus 3.9.2 搭最小双语站点(zh-Hans + en,只挂本插件),docusaurus build --no-minify 成功:日志 已从 en 输出移除 /oauth/ 副本,build/oauth/clients/desirecore-desktop-v1.json 保留且 MD5 仍为 aaf561fbedc1628a4edfee1a63a6b375,build/en/ 下没有 oauth/。
  • vercel.json 按 https://openapi.vercel.sh/vercel.json 官方 Schema 校验通过。
  • 合入后在生产核对:精确地址 200、application/json、438 字节、MD5 不变、Cache-Control: public, max-age=300;带斜杠地址 308 到精确地址;/en/ 地址 404。预览部署有访问保护,匿名 curl 看不到内容,所以只能在生产核对。

Verified with a minimal bilingual Docusaurus 3.9.2 site using this plugin (en copy removed, default copy byte-identical) and the official Vercel schema. Production headers will be re-checked after merge because preview deployments are access-protected.

检查清单 / Checklist

跟踪 / Tracking https://github.com/desirecore/desirecore/issues/5724

- /oauth/clients/* 的 Cache-Control 改为 public, max-age=300(原为 Vercel 默认的 max-age=0)。
- 末尾带斜杠的地址 308 到精确地址,不再直接返回文档。
- 新增 oauth-client-metadata-plugin:构建非默认语言时删除 static/ 复制进来的 oauth/ 副本,/en/oauth/clients/... 返回 404。

文档 URL 本身就是公开的 client_id,别名地址不是身份(desirecore/desirecore#5724、ADR-341)。
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 27, 2026 8:20am UTC

Request Review

@yi-ge
yi-ge merged commit 2a3057c into main Nov 27, 2026
6 checks passed
@yi-ge
yi-ge deleted the fix/oauth-client-metadata-exact-url branch November 27, 2026 10:19

This branch was successfully deployed

1 active deployment
Preview — f585ccb7 Deployed Nov 27, 2026 by vercel[bot]
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