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

Method authPhysicalJSONByIndex

internal/pluginhost/auth_callbacks.go:236–260  ·  view source on GitHub ↗
(authIndex string)

Source from the content-addressed store, hash-verified

234}
235
236func (h *Host) authPhysicalJSONByIndex(authIndex string) (*coreauth.Auth, []byte, error) {
237 auth, errGet := h.authByIndex(authIndex)
238 if errGet != nil {
239 return nil, nil, errGet
240 }
241 path := strings.TrimSpace(authAttribute(auth, "path"))
242 if path == "" {
243 return nil, nil, fmt.Errorf("auth file path not found for auth_index %s", authIndex)
244 }
245 data, errRead := os.ReadFile(path)
246 if errRead != nil {
247 if os.IsNotExist(errRead) {
248 return nil, nil, fmt.Errorf("auth file not found for auth_index %s", authIndex)
249 }
250 return nil, nil, fmt.Errorf("failed to read auth file: %w", errRead)
251 }
252 if len(bytesTrimSpace(data)) == 0 {
253 return nil, nil, fmt.Errorf("auth file is empty for auth_index %s", authIndex)
254 }
255 var metadata map[string]any
256 if errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {
257 return nil, nil, fmt.Errorf("invalid auth file for auth_index %s: %w", authIndex, errUnmarshal)
258 }
259 return auth, data, nil
260}
261
262func validateHostAuthSaveRequest(req pluginapi.HostAuthSaveRequest) (string, []byte, error) {
263 name := strings.TrimSpace(req.Name)

Callers 1

callHostAuthGetMethod · 0.95

Calls 3

authByIndexMethod · 0.95
bytesTrimSpaceFunction · 0.85
authAttributeFunction · 0.70

Tested by

no test coverage detected