Browse code

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 authored on 2016/02/12 03:30:56
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"fmt"
7 7
 	"io"
8 8
 	"io/ioutil"
9
+	"net/url"
9 10
 	"os"
10 11
 	"runtime"
11 12
 
... ...
@@ -17,6 +18,7 @@ import (
17 17
 	"github.com/docker/distribution/manifest/schema2"
18 18
 	"github.com/docker/distribution/registry/api/errcode"
19 19
 	"github.com/docker/distribution/registry/client"
20
+	"github.com/docker/distribution/registry/client/auth"
20 21
 	"github.com/docker/distribution/registry/client/transport"
21 22
 	"github.com/docker/docker/distribution/metadata"
22 23
 	"github.com/docker/docker/distribution/xfer"
... ...
@@ -710,6 +712,10 @@ func allowV1Fallback(err error) error {
710 710
 		if registry.ShouldV2Fallback(v) {
711 711
 			return fallbackError{err: err, confirmedV2: false}
712 712
 		}
713
+	case *url.Error:
714
+		if v.Err == auth.ErrNoBasicAuthCredentials {
715
+			return fallbackError{err: err, confirmedV2: false}
716
+		}
713 717
 	}
714 718
 
715 719
 	return err