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

Function homeQueryCredentialFromContext

sdk/cliproxy/auth/conductor.go:4726–4759  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

4724}
4725
4726func homeQueryCredentialFromContext(ctx context.Context) (string, bool) {
4727 if ctx == nil {
4728 return "", false
4729 }
4730 if queryCtx, ok := ctx.Value("gin").(interface{ Query(string) string }); ok && queryCtx != nil {
4731 if apiKey := strings.TrimSpace(queryCtx.Query("key")); apiKey != "" {
4732 return apiKey, true
4733 }
4734 if apiKey := strings.TrimSpace(queryCtx.Query("auth_token")); apiKey != "" {
4735 return apiKey, true
4736 }
4737 }
4738 ginCtx, ok := ctx.Value("gin").(interface{ Get(string) (any, bool) })
4739 if !ok || ginCtx == nil {
4740 return "", false
4741 }
4742 rawMetadata, ok := ginCtx.Get("accessMetadata")
4743 if !ok {
4744 return "", false
4745 }
4746 source := accessMetadataSource(rawMetadata)
4747 if source != "query-key" && source != "query-auth-token" {
4748 return "", false
4749 }
4750 rawAPIKey, ok := ginCtx.Get("userApiKey")
4751 if !ok {
4752 return "", false
4753 }
4754 apiKey := contextStringValue(rawAPIKey)
4755 if apiKey == "" {
4756 return "", false
4757 }
4758 return apiKey, true
4759}
4760
4761func accessMetadataSource(raw any) string {
4762 switch v := raw.(type) {

Callers 1

homeDispatchHeadersFunction · 0.85

Calls 4

accessMetadataSourceFunction · 0.85
contextStringValueFunction · 0.85
QueryMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected