Skip to content

Commit 139a79d

Browse files
dhowdenBryan C. Mills
authored andcommitted
cmd/go/internal/auth: fix .netrc lookup for URLs with specified port
The .netrc spec [1] defines credentials based on "machine name", so remove specified ports from URL before looking for a match. [1] https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html Fixes golang#37130 Change-Id: Iab993afba26c927454d6166111ad1e1a53dbce43 Reviewed-on: https://go-review.googlesource.com/c/go/+/218418 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 65bd076 commit 139a79d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/cmd/go/internal/auth/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import "net/http"
1010
// AddCredentials fills in the user's credentials for req, if any.
1111
// The return value reports whether any matching credentials were found.
1212
func AddCredentials(req *http.Request) (added bool) {
13+
host := req.URL.Hostname()
14+
1315
// TODO(golang.org/issue/26232): Support arbitrary user-provided credentials.
1416
netrcOnce.Do(readNetrc)
1517
for _, l := range netrc {
16-
if l.machine == req.URL.Host {
18+
if l.machine == host {
1719
req.SetBasicAuth(l.login, l.password)
1820
return true
1921
}

0 commit comments

Comments
 (0)