New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: .netrc credentials are not forward to GOPROXY if they do not contain password #40215
Comments
Thanks for opening this. What's the correct behavior here? Should we report an error for a netrc file like this (probably only when we would contact the machine in question)? Or should we send a request with a username and no password? The former seems more correct to me, but we should be consistent with other systems. |
An addition I forgot to include: this is the line where it appends to the netrc lines that will be forwarded to the GOPROXY, note that it checks that both a login/password must exist: go/src/cmd/go/internal/auth/netrc.go Line 65 in fa98f46
|
@marwan-at-work, how would you expect the request to be encoded? (As an HTTPS Basic Auth request with the empty string as the password, or something else?) RFC 7617 isn't exactly clear on the matter... |
@bcmills at least for GitHub, that is I believe what happens. To test this out, you can use a GitHub token to get your profile information like so:
From the verbose output, you can see the Authorization header which then you can decode its base64 value and see that it looks like this:
So the token is basically the basic auth user, and there is no password after the Finally, you can confirm that the GitHub API was happy with this and it successfully returns your profile info based on that token. To be honest, I don't know if this behavior is intentional, accidental, or just unique to GitHub. I just noticed that the .netrc file has always worked against GitHub like this and was surprised to see that Go didn't follow the same rules when forwarding credentials to a GOPROXY and had to dig into the code to find out why. Thanks! |
I'd like more authoritative confirmation than “GitHub does it”, but if someone can find such a confirmation that seems like a reasonable approach to me. |
I'd be interested to hear something more authoritative, as well, but after surveying the behaviors of other tools these are the main options I see (not all mutually exclusive):
There are several different things to consider:
When I started writing this, my preference was leaning in the direction of the The The HTTP tools, OTOH, seem to provide competing interpretations of what may or may not represent an empty password in the
Even though they agree about how to represent an empty password via HTTP Basic Auth, they do not agree amongst themselves what constitutes an empty or missing password in the Others might be able to offer counter examples, but considering what appears to me to be the historical (relative) consistency in the interpretation of the absence of the However, if an empty string password is then obtained by some other means, I think Notes on the above:
One last note: I should also clarify my apparently contradictory comments above about about how $ http --verbose --ignore-netrc 'http://someone@fake1.example.com:7777/' |
Thanks everyone for the interaction in here. Unfortunatley we didn't make much progress thus I am going to punt this to Go1.17 perhaps. Please feel free to change this otherwise though. |
Is anything going to happen here for 1.17? |
Go currently allows a user to forward credentials to a GOPROXY using a .netrc file. However, if I specify my .netrc file as follows:
machine myproxy.com login mytoken
Go will silently fail and will not send the credentials to myproxy.com unless I explicitly put
machine myproxy.com login myuser password mytoken
.In other words, I must have both "login" and "password" values.
On the other hand,
machine github.com login mytoken
works just fine for VCS authentication (since this is handled by git and libcurl directly and not by Go which they do allow you to specify only the "login" without a "password")To reproduce:
machine localhost:3000 login myToken
go mod init tmp
GOPATH=/tmp/empty/dir GOPROXY=https://localhost:3000,proxy.golang.org go get github.com/pkg/errors
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
Extracted from #40189 (see #40189 (comment))
The text was updated successfully, but these errors were encountered: