瀏覽代碼

Fall back to V1 when there are no basic auth credentials

This makes the behavior consistent with having incorrect credentials.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Aaron Lehmann 9 年之前
父節點
當前提交
7b81bc147c
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      distribution/pull_v2.go

+ 6 - 0
distribution/pull_v2.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
+	"net/url"
 	"os"
 	"runtime"
 
@@ -17,6 +18,7 @@ import (
 	"github.com/docker/distribution/manifest/schema2"
 	"github.com/docker/distribution/registry/api/errcode"
 	"github.com/docker/distribution/registry/client"
+	"github.com/docker/distribution/registry/client/auth"
 	"github.com/docker/distribution/registry/client/transport"
 	"github.com/docker/docker/distribution/metadata"
 	"github.com/docker/docker/distribution/xfer"
@@ -710,6 +712,10 @@ func allowV1Fallback(err error) error {
 		if registry.ShouldV2Fallback(v) {
 			return fallbackError{err: err, confirmedV2: false}
 		}
+	case *url.Error:
+		if v.Err == auth.ErrNoBasicAuthCredentials {
+			return fallbackError{err: err, confirmedV2: false}
+		}
 	}
 
 	return err