MCPcopy Create free account
hub / github.com/coder/coder / makeProxyAuthHeader

Function makeProxyAuthHeader

enterprise/aibridgeproxyd/aibridgeproxyd.go:705–719  ·  view source on GitHub ↗

makeProxyAuthHeader creates a Proxy-Authorization header value from URL user info. Valid formats: - username:password -> Basic auth with both credentials - username: or username -> Basic auth with username only (empty password) - :password -> Basic auth with empty username (token-based proxies) Re

(userInfo *url.Userinfo)

Source from the content-addressed store, hash-verified

703//
704// Returns empty string when both username and password are empty.
705func makeProxyAuthHeader(userInfo *url.Userinfo) string {
706 if userInfo == nil {
707 return ""
708 }
709
710 username := userInfo.Username()
711 password, _ := userInfo.Password()
712
713 // Reject only when both username and password are empty (no credentials).
714 if username == "" && password == "" {
715 return ""
716 }
717
718 return "Basic " + base64.StdEncoding.EncodeToString([]byte(userInfo.String()))
719}
720
721// extractCoderTokenFromProxyAuth extracts the Coder token from the
722// Proxy-Authorization header. The token is expected to be in the password

Callers 3

newReloadTestHarnessFunction · 0.70
NewFunction · 0.70

Calls 1

StringMethod · 0.45