MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / RedactBasicAuthURL

Function RedactBasicAuthURL

base/util.go:101–116  ·  view source on GitHub ↗
(urlIn string, passwordOnly bool)

Source from the content-addressed store, hash-verified

99}
100
101func RedactBasicAuthURL(urlIn string, passwordOnly bool) (string, error) {
102 urlParsed, err := url.Parse(urlIn)
103 if err != nil {
104 // err can't be wrapped or logged as it contains unredacted data from the provided url
105 return "", fmt.Errorf("unable to redact URL, returning empty string")
106 }
107 if urlParsed.User != nil {
108 user := urlParsed.User.Username()
109 if !passwordOnly {
110 user = RedactedStr
111 }
112 urlParsed.User = url.UserPassword(user, RedactedStr)
113 }
114
115 return urlParsed.String(), nil
116}
117
118// GenerateRandomSecret returns a cryptographically-secure 160-bit random number encoded as a hex string.
119func GenerateRandomSecret() (string, error) {

Callers 2

Calls 2

ErrorfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected