Skip to content

fix(gateway): mask Claude API keys in logs and request files#7

Merged
Chat2DB-Pro merged 1 commit into
OtterMind:mainfrom
oopswoo3:fix/claude-gateway-log-redaction
Jun 18, 2026
Merged

fix(gateway): mask Claude API keys in logs and request files#7
Chat2DB-Pro merged 1 commit into
OtterMind:mainfrom
oopswoo3:fix/claude-gateway-log-redaction

Conversation

@oopswoo3

Copy link
Copy Markdown
Contributor

Summary

  • 新增 ApiKeyLogMask 工具类,日志中 API Key 仅保留首尾各 4 位
  • ClaudeGatewayService 所有 log.infoApiRequestLogService.logRequest 入参改为脱敏后的 key
  • 计费/用量追踪(trackApiUsage)仍使用原始 key,行为不变

Why

OpenAI 网关路径已对 client API Key 做掩码,且 ApiRequestLogService 文档约定传入「掩码后的 key」;Claude 路径此前写入明文,会泄露到应用日志与 ai-gateway-logs 目录。

Test plan

  • mvn test -Dtest=ApiKeyLogMaskTest

Align ClaudeGatewayService with OpenAI gateway paths and ApiRequestLogService
contract by redacting client API keys before info logs and persisted request logs.
@Chat2DB-Pro Chat2DB-Pro merged commit ff843ae into OtterMind:main Jun 18, 2026
1 check passed
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.

2 participants