You've already forked agentic-coding-workflow
refactor(mcp): apply Part 1 review I1+I3+I4+I5
- Rename MCPToken -> Token (mcp.Token reads cleaner; zero external callers yet) - IssueSystemToken: guard against nil ACPSessionID / UserID (early input validation) - TokenService: inject now func for clock injection (parity with RateLimiter) - Repository CHECK constraint tests: assert wrapped CodeInternal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// - 工具/prompts/resources 的业务桥接(调 project / chat 现有 service)
|
||||
//
|
||||
// 三类核心抽象:
|
||||
// - MCPToken:DB 行记录,token plaintext 仅签发时返回一次
|
||||
// - Token:DB 行记录,token plaintext 仅签发时返回一次
|
||||
// - Scope:JSONB 形态的工具白名单 + project_ids 限定
|
||||
// - Issuer:'system' 或 'admin',决定生命期与是否绑定 ACP session
|
||||
package mcp
|
||||
@@ -76,11 +76,11 @@ func (s *Scope) AllowsProject(id uuid.UUID) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// MCPToken 是 mcp_tokens 表的 Go 表示。
|
||||
// Token 是 mcp_tokens 表的 Go 表示。
|
||||
//
|
||||
// TokenHash 是 SHA-256(plaintext);plaintext 仅在 IssueAdmin/IssueSystemToken
|
||||
// 的返回值里出现一次,DB 与本结构都不持有 plaintext。
|
||||
type MCPToken struct {
|
||||
type Token struct {
|
||||
ID uuid.UUID
|
||||
TokenHash []byte
|
||||
UserID uuid.UUID
|
||||
@@ -97,7 +97,7 @@ type MCPToken struct {
|
||||
|
||||
// IsActive 报告 token 当前是否可用(未撤销 + 未过期)。
|
||||
// now 显式注入便于测试;生产调用方传 time.Now()。
|
||||
func (t *MCPToken) IsActive(now time.Time) bool {
|
||||
func (t *Token) IsActive(now time.Time) bool {
|
||||
if t.RevokedAt != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user