-
-
Notifications
You must be signed in to change notification settings - Fork 180
fix: 修复 my-usage 今日统计与只读 API 自助查询 #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] [LOGIC-BUG]
bearerAuth在 adapter 通过,但多数 action 仍依赖 Cookie 的getSession(),导致 Bearer-only 调用失败Why this is a problem:
createActionRoute现在允许从Authorization: Bearer <token>读取 token 并通过validateKey()放行,但多数 server action(包括本 PR 新增暴露的my-usage)仍在 action 内部调用getSession(),而getSession()只读取auth-tokenCookie。结果是:Bearer-only(不带 Cookie)的脚本/CLI 请求会在 adapter 通过后,在 action 内部变成Unauthorized,最终返回 400。Evidence:
src/lib/api/action-adapter-openapi.ts:305-316:getCookie(c, "auth-token") ?? getBearerTokenFromAuthHeader(c.req.header("authorization"))src/lib/auth.ts:122-127:const keyString = await getAuthCookie();(没有从 Authorization header 取值)src/actions/my-usage.ts:149-150:const session = await getSession({ allowReadOnlyAccess: true }); if (!session) return { ok: false, error: "Unauthorized" };src/app/api/actions/[...route]/route.ts:59-65Suggested fix: 让
getSession()(或getAuthCookie())在 Cookie 缺失时回退读取Authorization: Bearer,并补充 Bearer-only 的 API 测试。