Skip to content

Commit 1b072f7

Browse files
authored
Merge pull request moby#50371 from thaJeztah/push_auth_body
daemon/server: remove compatibility with API v1.4 auth-config on push
2 parents d82900d + ea29dff commit 1b072f7

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)