mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 20:58:00 +00:00
fix: restore auth stripping on redirect, keyed off AuthHeader
This commit is contained in:
parent
3feb248ce1
commit
4e8321af97
@ -121,6 +121,15 @@ func (c *Cacher) Fetch() (updated bool, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{Timeout: timeout, Transport: transport}
|
client := &http.Client{Timeout: timeout, Transport: transport}
|
||||||
|
if c.AuthHeader != "" {
|
||||||
|
// Strip auth before following any redirect — redirect targets (e.g.
|
||||||
|
// presigned S3/R2 URLs) must not receive our credentials.
|
||||||
|
authHeader := c.AuthHeader
|
||||||
|
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
|
req.Header.Del(authHeader)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user