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)
| 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. |
| 29 | func 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 |
no test coverage detected