fix(swarm): don't stomp on the x-registry-auth header EE-3308 (#7080)

* don't stomp on the x-registry-auth header

* del header if empty json provided for registry auth
pull/7050/head
Matt Hook 2 years ago committed by GitHub
parent 461fc91446
commit 6d6c70a98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ type (
} }
portainerRegistryAuthenticationHeader struct { portainerRegistryAuthenticationHeader struct {
RegistryId portainer.RegistryID `json:"registryId"` RegistryId *portainer.RegistryID `json:"registryId"`
} }
) )

@ -446,7 +446,20 @@ func (transport *Transport) decorateRegistryAuthenticationHeader(request *http.R
return err return err
} }
authenticationHeader, err := createRegistryAuthenticationHeader(transport.dataStore, originalHeaderData.RegistryId, accessContext) // delete header and exist function without error if Front End
// passes empty json. This is to restore original behavior which
// never originally passed this header
if string(decodedHeaderData) == "{}" {
request.Header.Del("X-Registry-Auth")
return nil
}
// only set X-Registry-Auth if registryId is defined
if originalHeaderData.RegistryId == nil {
return nil
}
authenticationHeader, err := createRegistryAuthenticationHeader(transport.dataStore, *originalHeaderData.RegistryId, accessContext)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save