Include the username in the creds call if present

This is needed to disambiguate cases where a user has multiple usernames
on the same host. Without this the first item will be silently used
which might be wrong & cause a loop of incorrect password prompts (&
possibly a lockout on the server)
This commit is contained in:
Steve Streeting 2015-09-02 13:03:51 +01:00
parent d7aa084533
commit d806269594

@ -105,6 +105,9 @@ func getCredURLForAPI(req *http.Request) (*url.URL, error) {
func fillCredentials(u *url.URL) (Creds, error) {
path := strings.TrimPrefix(u.Path, "/")
creds := Creds{"protocol": u.Scheme, "host": u.Host, "path": path}
if u.User != nil && u.User.Username() != "" {
creds["username"] = u.User.Username()
}
return execCreds(creds, "fill")
}