Watch
1
0
Fork
You've already forked pkg-proxy
1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-11-10 08:09:17 -05:00
pkg-proxy/internal/handler/upstream_auth_helper_test.go

21 lines
592 B
Go
Raw Permalink Normal View History

package handler
import (
"net/http"
upstreamhttp "github.com/git-pkgs/proxy/internal/httpclient"
)
// authorizeUpstream sends authorization on every upstream request the way the
// server does: through the auth transport, which scopes it to each hop.
func authorizeUpstream(proxy *Proxy, authorization string) {
base := proxy.HTTPClient.Transport
if base == nil {
base = http.DefaultTransport
}
client := *proxy.HTTPClient
client.Transport = upstreamhttp.NewTransport(base, func(string) (string, string) {
return "Authorization", authorization
})
proxy.HTTPClient = &client
}