MCPcopy
hub / github.com/elastic/go-elasticsearch / BasicAuth

Function BasicAuth

_examples/interceptor/internal/redact/basic.go:29–35  ·  view source on GitHub ↗

BasicAuth extracts basic auth credentials from the request and returns the username and a masked password. The password is masked to show only the first and last characters if it's 5+ characters long, otherwise it's fully masked. Returns empty strings and false if no auth is present.

(r *http.Request)

Source from the content-addressed store, hash-verified

27// the first and last characters if it's 5+ characters long, otherwise
28// it's fully masked. Returns empty strings and false if no auth is present.
29func BasicAuth(r *http.Request) (username, maskedPassword string, ok bool) {
30 username, password, ok := r.BasicAuth()
31 if !ok {
32 return "", "", false
33 }
34 return username, MaskPassword(password), true
35}
36
37// MaskPassword masks a password string, showing only the first and last
38// characters if the password is 5+ characters long. Passwords shorter

Callers 2

mainFunction · 0.92
mainFunction · 0.92

Calls 1

MaskPasswordFunction · 0.85

Tested by

no test coverage detected