-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Labels
authenticationenhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codegood first issueGood for newcomersGood for newcomers
Description
Context
The vMCP authentication system currently uses magic strings for strategy types and metadata keys throughout the codebase. This was flagged in PR #2451 review as something that should use defined constants instead.
Current Usage of Magic Strings
Strategy Types:
"header_injection"inpkg/vmcp/auth/strategies/outgoing.go"unauthenticated"inpkg/vmcp/auth/strategies/outgoing.go
Metadata Keys:
"header_name"inpkg/vmcp/auth/strategies/header_injection.go"header_value"inpkg/vmcp/auth/strategies/header_injection.go
Proposed Change
Create pkg/vmcp/auth/strategies/constants.go:
package strategies
// Strategy type identifiers
const (
StrategyTypeUnauthenticated = "unauthenticated"
StrategyTypeHeaderInjection = "header_injection"
// Future: StrategyTypeTokenExchange, StrategyTypeServiceAccount, etc.
)
// Metadata key names
const (
MetadataHeaderName = "header_name"
MetadataHeaderValue = "header_value"
// Future: MetadataTokenURL, MetadataClientID, etc.
)Then replace all magic strings with these constants throughout:
pkg/vmcp/auth/strategies/outgoing.gopkg/vmcp/auth/strategies/header_injection.gopkg/vmcp/auth/strategies/unauthenticated.gopkg/vmcp/config/yaml_loader.go(transform functions)
Benefits
- Type safety and autocomplete
- Single source of truth for string values
- Easier refactoring if names need to change
- Prevents typos in strategy/key names
- Self-documenting code
Related
Metadata
Metadata
Assignees
Labels
authenticationenhancementNew feature or requestNew feature or requestgoPull requests that update go codePull requests that update go codegood first issueGood for newcomersGood for newcomers