MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / NormalizeAuthConfigs

Function NormalizeAuthConfigs

internal/pluginstore/auth.go:36–74  ·  view source on GitHub ↗
(auth []AuthConfig)

Source from the content-addressed store, hash-verified

34}
35
36func NormalizeAuthConfigs(auth []AuthConfig) []AuthConfig {
37 if len(auth) == 0 {
38 return nil
39 }
40 out := make([]AuthConfig, 0, len(auth))
41 for _, item := range auth {
42 item.Match = strings.TrimSpace(item.Match)
43 item.Type = strings.ToLower(strings.TrimSpace(item.Type))
44 item.TokenEnv = strings.TrimSpace(item.TokenEnv)
45 item.UsernameEnv = strings.TrimSpace(item.UsernameEnv)
46 item.PasswordEnv = strings.TrimSpace(item.PasswordEnv)
47 item.HeaderName = strings.TrimSpace(item.HeaderName)
48 item.HeaderValueEnv = strings.TrimSpace(item.HeaderValueEnv)
49 if item.Type == "" {
50 item.Type = AuthTypeNone
51 }
52 if item.Match == "" {
53 continue
54 }
55 if len(item.ApplyTo) > 0 {
56 applyTo := make([]string, 0, len(item.ApplyTo))
57 seen := map[string]struct{}{}
58 for _, value := range item.ApplyTo {
59 value = strings.ToLower(strings.TrimSpace(value))
60 if value == "" {
61 continue
62 }
63 if _, exists := seen[value]; exists {
64 continue
65 }
66 seen[value] = struct{}{}
67 applyTo = append(applyTo, value)
68 }
69 item.ApplyTo = applyTo
70 }
71 out = append(out, item)
72 }
73 return out
74}
75
76func AuthConfigured(auth []AuthConfig, requestURL string, kind string) bool {
77 item, ok := matchingAuthConfig(auth, requestURL, kind)

Callers 1

matchingAuthConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected