Remove deprecated API-key aliases and complete AgentID rename#7159
Conversation
There was a problem hiding this comment.
Pull request overview
This PR continues the AgentID migration by removing deprecated API-key alias entry points, updating remaining call sites to use the canonical AgentID APIs, and completing the random key generator rename to match the AgentID naming convention.
Changes:
- Removed deprecated alias functions for API-key-style accessors/validators in
internal/authandinternal/config. - Renamed the random key generator from
GenerateRandomAPIKeytoGenerateRandomAgentIDand updated the startup call path. - Aligned tests with the new generator name and removed the obsolete alias test.
Show a summary per file
| File | Description |
|---|---|
| internal/server/middleware.go | Updates internal/auth API reference in the auth middleware comment. |
| internal/config/config_env.go | Removes deprecated GetGatewayAPIKeyFromEnv wrapper. |
| internal/config/config_core.go | Removes deprecated (*Config).GetAPIKey wrapper. |
| internal/cmd/root.go | Switches startup random generation call to GenerateRandomAgentID. |
| internal/auth/header.go | Removes deprecated ValidateAPIKey wrapper; renames random generator to GenerateRandomAgentID. |
| internal/auth/header_test.go | Removes the now-obsolete ValidateAPIKey alias test. |
| internal/auth/apikey_test.go | Renames random-generator tests to use GenerateRandomAgentID. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 2
| // GenerateRandomAgentID generates a cryptographically random agent ID. | ||
| // Per spec §7.3, the gateway SHOULD generate a random API key on startup | ||
| // if none is provided. Returns a 32-byte hex-encoded string (64 chars). |
| // For header parsing logic, see internal/auth package which provides: | ||
| // - ParseAuthHeader() for extracting API keys and agent IDs | ||
| // - ValidateAPIKey() for key validation | ||
| // - ValidateAgentID() for key validation | ||
| func authMiddleware(apiKey string, next http.HandlerFunc) http.HandlerFunc { |
|
@copilot resolve the merge conflicts in this pull request and address review feedback |
Done in |
This change removes duplicate deprecated API-key forwarding functions that were kept after the AgentID rename, and migrates remaining usage to the canonical AgentID APIs. It also completes the unfinished rename of random key generation to the AgentID naming convention.
Problem summary
Alias/API surface cleanup
auth.ValidateAPIKey→ useauth.ValidateAgentID(*config.Config).GetAPIKey→ use(*config.Config).GetAgentIDconfig.GetGatewayAPIKeyFromEnv→ useconfig.GetGatewayAgentIDFromEnvGenerator rename completion
auth.GenerateRandomAPIKeytoauth.GenerateRandomAgentID.internal/cmd/root.goto use the new symbol.Test alignment
ValidateAPIKey.