feat: bind MCP user context tokens to audience and add unique jti - #740
Open
Stella-sea wants to merge 3 commits into
Open
Stella-sea wants to merge 3 commits into
Stella-sea wants to merge 3 commits into
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
给 #737 引入的签名 MCP 用户上下文 token 补上两个通用声明:
aud和jti。#737 之后,签出的 token 对任何管理员注册的 MCP server 都有效——同一 token 可以在多个服务端之间重放,服务端也无法对单次调用做幂等。本 PR:
aud:绑定目标服务地址(strings.TrimSpace(CallConfig.BaseURL),与管理员注册值一致)。服务端校验时比对自身注册地址,即可拒绝重放到其他服务端的 token。jti:每次 tools/call 签发唯一 ID(uuid v4)。服务端可用它做 TTL 窗口内的重放防护和幂等键。Change type
Affected areas
Verification
gofmt -l:干净go vet ./internal/pkg/mcpauth/...:通过go test ./internal/pkg/mcpauth/... -count=1:全部通过(含新增的 aud/jti 往返用例)Configuration, migration, and compatibility notes
omitempty,签名算法、格式、密钥配置均不变。aud/jti。