fetch.WithAllowPrivateHosts (added in #51, released in v0.7.0) stores an allowlist that only the fetcher's default DialContext consults via gateOptions. When a caller passes fetch.WithHTTPClient, that default transport is replaced and the allowlist is never read.
git-pkgs/proxy builds its own safehttp.New(nil, safehttp.Options{}) client so it can wrap the transport with auth and access-log layers before passing it to fetch.NewFetcher(fetch.WithHTTPClient(...)). Under that composition there's no way to allowlist a private-network upstream: safehttp.Options only offers the blanket AllowPrivate / AllowLoopback booleans, and fetch.WithAllowPrivateHosts has no effect on an injected client. The metadata http.Client the proxy uses directly (outside the fetcher) has the same limitation.
Suggested change: add AllowPrivateHosts []string (matched via the existing normalizeHost) to safehttp.Options and have the safehttp DialContext apply AllowPrivate for those hosts only. fetch.WithAllowPrivateHosts can then set it on the default client's options rather than keeping a separate map, so both the default and injected-client paths behave the same.
Blocks git-pkgs/proxy#223.
fetch.WithAllowPrivateHosts(added in #51, released in v0.7.0) stores an allowlist that only the fetcher's defaultDialContextconsults viagateOptions. When a caller passesfetch.WithHTTPClient, that default transport is replaced and the allowlist is never read.git-pkgs/proxy builds its own
safehttp.New(nil, safehttp.Options{})client so it can wrap the transport with auth and access-log layers before passing it tofetch.NewFetcher(fetch.WithHTTPClient(...)). Under that composition there's no way to allowlist a private-network upstream:safehttp.Optionsonly offers the blanketAllowPrivate/AllowLoopbackbooleans, andfetch.WithAllowPrivateHostshas no effect on an injected client. The metadatahttp.Clientthe proxy uses directly (outside the fetcher) has the same limitation.Suggested change: add
AllowPrivateHosts []string(matched via the existingnormalizeHost) tosafehttp.Optionsand have thesafehttpDialContext applyAllowPrivatefor those hosts only.fetch.WithAllowPrivateHostscan then set it on the default client's options rather than keeping a separate map, so both the default and injected-client paths behave the same.Blocks git-pkgs/proxy#223.