Skip to content

Commit dfa7ebe

Browse files
committed
Fix header_injection metadata parsing in YAML loader
Add dedicated rawHeaderInjectionAuth struct and update transformBackendAuthStrategy to properly parse header_injection configuration from YAML files. Previously, the header_injection strategy used a generic metadata field in YAML, but the transform function had no case to handle it, resulting in empty metadata maps. This follows the established pattern used by token_exchange and service_account strategies. The YAML format is now consistent across all strategies: backends: github: type: header_injection header_injection: header_name: Authorization header_value: Bearer xxx
1 parent 904739c commit dfa7ebe

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

pkg/vmcp/config/yaml_loader.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ type rawOutgoingAuth struct {
7878
}
7979

8080
type rawBackendAuthStrategy struct {
81-
Type string `yaml:"type"`
82-
TokenExchange *rawTokenExchangeAuth `yaml:"token_exchange"`
83-
ServiceAccount *rawServiceAccountAuth `yaml:"service_account"`
81+
Type string `yaml:"type"`
82+
HeaderInjection *rawHeaderInjectionAuth `yaml:"header_injection"`
83+
TokenExchange *rawTokenExchangeAuth `yaml:"token_exchange"`
84+
ServiceAccount *rawServiceAccountAuth `yaml:"service_account"`
85+
}
86+
87+
type rawHeaderInjectionAuth struct {
88+
HeaderName string `yaml:"header_name"`
89+
HeaderValue string `yaml:"header_value"`
8490
}
8591

8692
type rawTokenExchangeAuth struct {
@@ -304,6 +310,19 @@ func (*YAMLLoader) transformBackendAuthStrategy(raw *rawBackendAuthStrategy) (*B
304310
}
305311

306312
switch raw.Type {
313+
case "header_injection":
314+
if raw.HeaderInjection == nil {
315+
return nil, fmt.Errorf("header_injection configuration is required")
316+
}
317+
318+
strategy.Metadata = map[string]any{
319+
"header_name": raw.HeaderInjection.HeaderName,
320+
"header_value": raw.HeaderInjection.HeaderValue,
321+
}
322+
323+
case "unauthenticated":
324+
// No metadata required for unauthenticated strategy
325+
307326
case "token_exchange":
308327
if raw.TokenExchange == nil {
309328
return nil, fmt.Errorf("token_exchange configuration is required")

0 commit comments

Comments
 (0)