golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.41k stars 17.59k forks source link

x/pkgsite/cmd/pkgsite: local pkgsite with -proxy doesn't use netrc auth to private GOPROXY #60299

Open dnwe opened 1 year ago

dnwe commented 1 year ago

What did you do?

Attempted to use a .netrc file to provide credentials to pkgsite for use when fetching via a private GOPROXY.

The regular go mod commands are able to do this, so with a properly configured .netrc file the following succeeds:

GOPROXY="https://goproxy.company.com" go mod download -x github.company.com/org/repo@latest

But attempting to view the documentation of github.company.com/org/repo via pkgsite:

GOPROXY="https://goproxy.company.com" pkgsite -proxy

Fails with 401 authentication errors as the internal/proxy/client.go code doesn't attempt to insert authentication headers, unlike cmd/go which does

What did you expect to see?

pkgsite should be able to use authentication against a private GOPROXY

What did you see instead?

pkgsite does not pass authentication headers to the http requests it makes to a private GOPROXY

mxk commented 5 months ago

Did you ever find a solution to this? I finally managed to configure athens proxy to get private repos, but the links rendered by pkgsite frontend aren't pointing at the right files.

mxk commented 5 months ago

For anyone else who runs into this issue, I managed to work around it by passing HTTP_PROXY and HTTPS_PROXY to frontend and running a custom proxy server that injects credentials from netrc. Really ugly, but it works without having to modify pkgsite source.