MCPcopy Create free account
hub / github.com/github/gh-aw / parseAuthDefinition

Function parseAuthDefinition

pkg/workflow/engine_config_parser.go:104–128  ·  view source on GitHub ↗

parseAuthDefinition converts a raw auth config map (from engine.provider.auth) into an AuthDefinition. It is backward-compatible: a map with only a "secret" key produces an AuthDefinition with Strategy="" and Secret set (callers normalise Strategy to api-key).

(authObj map[string]any)

Source from the content-addressed store, hash-verified

102// an AuthDefinition. It is backward-compatible: a map with only a "secret" key produces
103// an AuthDefinition with Strategy="" and Secret set (callers normalise Strategy to api-key).
104func parseAuthDefinition(authObj map[string]any) *AuthDefinition {
105 def := &AuthDefinition{}
106 if s, ok := authObj["strategy"].(string); ok {
107 def.Strategy = AuthStrategy(s)
108 }
109 if s, ok := authObj["secret"].(string); ok {
110 def.Secret = s
111 }
112 if s, ok := authObj["token-url"].(string); ok {
113 def.TokenURL = s
114 }
115 if s, ok := authObj["client-id"].(string); ok {
116 def.ClientIDRef = s
117 }
118 if s, ok := authObj["client-secret"].(string); ok {
119 def.ClientSecretRef = s
120 }
121 if s, ok := authObj["token-field"].(string); ok {
122 def.TokenField = s
123 }
124 if s, ok := authObj["header-name"].(string); ok {
125 def.HeaderName = s
126 }
127 return def
128}
129
130// parseEngineAuthConfig converts a raw engine.auth config map into EngineAuthConfig.
131func parseEngineAuthConfig(authObj map[string]any) *EngineAuthConfig {

Callers 2

ExtractEngineConfigMethod · 0.85
TestParseAuthDefinitionFunction · 0.85

Calls 1

AuthStrategyTypeAlias · 0.85

Tested by 1

TestParseAuthDefinitionFunction · 0.68