ensure authorization header is included for http backends (#1657)

Signed-off-by: CalebTVanDyke <ctvandyke24@gmail.com>
This commit is contained in:
Caleb Van Dyke
2024-05-20 11:03:56 -05:00
committed by GitHub
parent 542ad1b29c
commit bffb968c1f
2 changed files with 25 additions and 1 deletions

View File

@@ -257,15 +257,20 @@ func (b *Backend) configure(ctx context.Context) error {
headers = make(map[string]string, len(dh))
for k, v := range dh {
value, ok := v.(string)
if !ok {
return fmt.Errorf("header value for %s must be a string", k)
}
switch strings.ToLower(k) {
case "authorization":
if username != "" {
return fmt.Errorf("headers \"%s\" cannot be set when providing username", k)
}
headers[k] = value
case "content-type", "content-md5":
return fmt.Errorf("headers \"%s\" is reserved", k)
default:
headers[k] = v.(string)
headers[k] = value
}
}
}