diff --git a/api/http/proxy/factory/docker/registry.go b/api/http/proxy/factory/docker/registry.go index 7992634f7..352c5a459 100644 --- a/api/http/proxy/factory/docker/registry.go +++ b/api/http/proxy/factory/docker/registry.go @@ -23,7 +23,7 @@ type ( } portainerRegistryAuthenticationHeader struct { - RegistryId portainer.RegistryID `json:"registryId"` + RegistryId *portainer.RegistryID `json:"registryId"` } ) diff --git a/api/http/proxy/factory/docker/transport.go b/api/http/proxy/factory/docker/transport.go index 0c13cc783..c04bb8a4e 100644 --- a/api/http/proxy/factory/docker/transport.go +++ b/api/http/proxy/factory/docker/transport.go @@ -446,7 +446,20 @@ func (transport *Transport) decorateRegistryAuthenticationHeader(request *http.R 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 { return err }