MCPcopy Index your code
hub / github.com/netdata/netdata / parseBasicAuth

Function parseBasicAuth

src/go/pkg/web/request_config_test.go:404–422  ·  view source on GitHub ↗
(auth string)

Source from the content-addressed store, hash-verified

402}
403
404func parseBasicAuth(auth string) (username, password string, ok bool) {
405 const prefix = "Basic "
406 if len(auth) < len(prefix) || !strings.EqualFold(auth[:len(prefix)], prefix) {
407 return "", "", false
408 }
409
410 decoded, err := base64.StdEncoding.DecodeString(auth[len(prefix):])
411 if err != nil {
412 return "", "", false
413 }
414
415 decodedStr := string(decoded)
416 before, after, ok0 := strings.Cut(decodedStr, ":")
417 if !ok0 {
418 return "", "", false
419 }
420
421 return before, after, true
422}

Callers 1

TestNewHTTPRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…