Skip to content

Commit ea29dff

Browse files
committed
daemon/server: remove compatibility with API v1.4 auth-config on push
Docker [API v1.4] and lower expected registry authentication to be sent in the request body when pushing or pulling ("creating") images. [API v1.5] (Docker v0.6.1) changed this to this to use a `X-Registry-Auth` header instead. This change was implemented in d04beb7, which kept a fallback for clients using old (< v1.5) API versions which would send authentication in the request body. Given that we no longer support API versions older than v1.24, and clients using API v1.5 would be over 12 Years old. [API v1.4]: https://github.com/moby/moby/blob/v0.6.1/docs/sources/api/docker_remote_api_v1.4.rst#push-an-image-on-the-registry [API v1.5]: https://github.com/moby/moby/blob/v0.6.2/docs/sources/api/docker_remote_api_v1.5.rst#push-an-image-on-the-registry Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent d4aa1cf commit ea29dff

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

api/types/registry/authconfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func DecodeAuthConfig(authEncoded string) (*AuthConfig, error) {
8383
// Like [DecodeAuthConfig], this function always returns an [AuthConfig], even if an
8484
// error occurs. It is up to the caller to decide if authentication is required,
8585
// and if the error can be ignored.
86+
//
87+
// Deprecated: this function is no longer used and will be removed in the next release.
8688
func DecodeAuthConfigBody(rdr io.ReadCloser) (*AuthConfig, error) {
8789
return decodeAuthConfigFromReader(rdr)
8890
}

api/types/registry/authconfig_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package registry
22

33
import (
4-
"io"
5-
"strings"
64
"testing"
75

86
"gotest.tools/v3/assert"
@@ -47,12 +45,6 @@ func TestDecodeAuthConfig(t *testing.T) {
4745
})
4846
}
4947

50-
func TestDecodeAuthConfigBody(t *testing.T) {
51-
token, err := DecodeAuthConfigBody(io.NopCloser(strings.NewReader(unencoded)))
52-
assert.NilError(t, err)
53-
assert.Equal(t, *token, expected)
54-
}
55-
5648
func TestEncodeAuthConfig(t *testing.T) {
5749
token, err := EncodeAuthConfig(expected)
5850
assert.NilError(t, err)

daemon/server/router/image/image_routes.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
100100

101101
// For a pull it is not an error if no auth was given. Ignore invalid
102102
// AuthConfig to increase compatibility with the existing API.
103+
//
104+
// TODO(thaJeztah): accept empty values but return an error when failing to decode.
103105
authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
104106
progressErr = ir.backend.PullImage(ctx, ref, platform, metaHeaders, authConfig, output)
105107
} else { // import
@@ -167,16 +169,11 @@ func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter
167169

168170
var authConfig *registry.AuthConfig
169171
if authEncoded := r.Header.Get(registry.AuthHeader); authEncoded != "" {
170-
// the new format is to handle the authConfig as a header. Ignore invalid
171-
// AuthConfig to increase compatibility with the existing API.
172+
// Handle the authConfig as a header, but ignore invalid AuthConfig
173+
// to increase compatibility with the existing API.
174+
//
175+
// TODO(thaJeztah): accept empty values but return an error when failing to decode.
172176
authConfig, _ = registry.DecodeAuthConfig(authEncoded)
173-
} else {
174-
// the old format is supported for compatibility if there was no authConfig header
175-
var err error
176-
authConfig, err = registry.DecodeAuthConfigBody(r.Body)
177-
if err != nil {
178-
return errors.Wrap(err, "bad parameters and missing X-Registry-Auth")
179-
}
180177
}
181178

182179
output := ioutils.NewWriteFlusher(w)

0 commit comments

Comments
 (0)