diff options
author | Milivoje Legenovic <m.legenovic@gmail.com> | 2021-01-19 23:12:14 +0100 |
---|---|---|
committer | Milivoje Legenovic <m.legenovic@gmail.com> | 2021-01-22 18:26:21 +0100 |
commit | c9baa6b93b38b96b2b85bfb732c3677f31574ba1 (patch) | |
tree | a5534cf1a3526d6956ce4eaa0d3b9163d0152fcc /pkg/auth | |
parent | 47616fe64720aedff76bbf37e46093800cdfee95 (diff) | |
download | podman-c9baa6b93b38b96b2b85bfb732c3677f31574ba1.tar.gz podman-c9baa6b93b38b96b2b85bfb732c3677f31574ba1.tar.bz2 podman-c9baa6b93b38b96b2b85bfb732c3677f31574ba1.zip |
Accept and ignore 'null' as value for X-Registry-Auth
docker-client is a library written in Java and used in Eclipse to
speak with Docker API. When endpoint /images/search is called,
HTTP header attribute X-Registry-Auth has value "null". This is for
sure wrong but Docker tolerates this value, and call works. With this
patch call works also with Podman. #7857
Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
Diffstat (limited to 'pkg/auth')
-rw-r--r-- | pkg/auth/auth.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index fcbf6fe39..86d92c028 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -297,7 +297,9 @@ func imageAuthToDockerAuth(authConfig types.DockerAuthConfig) dockerAPITypes.Aut func singleAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error) { authHeader := r.Header.Get(string(XRegistryAuthHeader)) authConfig := dockerAPITypes.AuthConfig{} - if len(authHeader) > 0 { + // Accept "null" and handle it as empty value for compatibility reason with Docker. + // Some java docker clients pass this value, e.g. this one used in Eclipse. + if len(authHeader) > 0 && authHeader != "null" { authJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authHeader)) if err := json.NewDecoder(authJSON).Decode(&authConfig); err != nil { return nil, err @@ -312,7 +314,9 @@ func singleAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error // The header content is a map[string]DockerAuthConfigs. func multiAuthHeader(r *http.Request) (map[string]types.DockerAuthConfig, error) { authHeader := r.Header.Get(string(XRegistryAuthHeader)) - if len(authHeader) == 0 { + // Accept "null" and handle it as empty value for compatibility reason with Docker. + // Some java docker clients pass this value, e.g. this one used in Eclipse. + if len(authHeader) == 0 || authHeader == "null" { return nil, nil } |