From 5afbf324000f8c9675ef02b9a7f88948f0c82a0e Mon Sep 17 00:00:00 2001 From: Sevki Hasirci Date: Sun, 14 Apr 2019 11:05:59 +0100 Subject: [PATCH] fix no error returned in fetchTokenWithOAuth fetchTokenWithBasicAuth checks if a token is in the token response but fetchTokenWithOAuth does not these changes implements the same behaviour for the latter returning a `ErrNoToken` if a token is not found in the resposne Signed-off-by: Sevki Hasirci --- registry/client/auth/session.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/registry/client/auth/session.go b/registry/client/auth/session.go index aad8a0e6..5d2322f3 100644 --- a/registry/client/auth/session.go +++ b/registry/client/auth/session.go @@ -366,6 +366,10 @@ func (th *tokenHandler) fetchTokenWithOAuth(realm *url.URL, refreshToken, servic return "", time.Time{}, fmt.Errorf("unable to decode token response: %s", err) } + if tr.AccessToken == "" { + return "", time.Time{}, ErrNoToken + } + if tr.RefreshToken != "" && tr.RefreshToken != refreshToken { th.creds.SetRefreshToken(realm, service, tr.RefreshToken) }