From cffb4bbbfd9bb31323fcadafc3f6f2120d74f769 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Wed, 10 Feb 2016 16:34:50 -0800 Subject: [PATCH] Export "no basic auth credentials" as an error value Making this an exported error value will allow users of the registry/client/auth module to have consistent behavior between authentication failures and cases where no credentials are provided. Signed-off-by: Aaron Lehmann --- docs/client/auth/session.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/client/auth/session.go b/docs/client/auth/session.go index 50a94a3d..f4c7ade4 100644 --- a/docs/client/auth/session.go +++ b/docs/client/auth/session.go @@ -15,6 +15,10 @@ import ( "github.com/docker/distribution/registry/client/transport" ) +// ErrNoBasicAuthCredentials is returned if a request can't be authorized with +// basic auth due to lack of credentials. +var ErrNoBasicAuthCredentials = errors.New("no basic auth credentials") + // AuthenticationHandler is an interface for authorizing a request from // params from a "WWW-Authenicate" header for a single scheme. type AuthenticationHandler interface { @@ -322,5 +326,5 @@ func (bh *basicHandler) AuthorizeRequest(req *http.Request, params map[string]st return nil } } - return errors.New("no basic auth credentials") + return ErrNoBasicAuthCredentials }