Repository navigation
fix(oauth): add bounded previous-token grace windows and sanitized diagnostics - #275
Merged
Merged
Conversation
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.
Summary
Refs #272
针对高频主动刷新 OAuth 令牌并紧接着并发请求
/mcp的客户端(如 Gemini Web),在保持原有 DCR + PKCE 刷新轮换与重放防护边界的前提下,补齐两块安全兼容与可观测性改动:/oauth/token刷新与令牌校验路径记录细分失败/放行原因(如previous_access_grace_accepted、刷新代际与状态原因),全程不包含任何access_token、refresh_token、code或明文凭据。oauthPreviousAccessGraceWindow = 60s(且不超过该令牌原始过期时间),仅保存 SHA-256 哈希、代际与截止时间戳,不持久化明文;用于吸收换新瞬间仍在途的并发/mcp请求。N-1) 宽限收敛:oauthRefreshGraceWindow = 30s、oauthRefreshGraceMaxUses = 1;单次正常轮换后最多吸收 1 次断包重试或并发刷新竞态,防止在宽限窗口内链式无限延长。Security Boundaries
30s宽限窗口、同一轮换周期内第 2 次重用N-1、或提交更早代(<= N-2)Refresh Token 时,仍然立即吊销整条 Grant。Verification
go test -race -count=1 ./internal/auth/... ./internal/httpx/...— all passed (internal/auth,internal/httpx,internal/httpx/requestmeta).