From 32a3ef7753a8da1abdd39f19c8e92846118ab219 Mon Sep 17 00:00:00 2001 From: "Lixia (Sylvia) Lei" Date: Thu, 21 Sep 2023 15:42:07 +0800 Subject: [PATCH] fix Signed-off-by: Lixia (Sylvia) Lei --- registry/remote/auth/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/registry/remote/auth/client.go b/registry/remote/auth/client.go index 22e7b8aa..59df4137 100644 --- a/registry/remote/auth/client.go +++ b/registry/remote/auth/client.go @@ -189,6 +189,7 @@ func (c *Client) Do(originalReq *http.Request) (*http.Response, error) { case SchemeBearer: // merge per-host scopes with generic scopes scopes := append(GetScopesPerHost(ctx, host), GetScopes(ctx)...) + scopes = CleanScopes(scopes) attemptedKey = strings.Join(scopes, " ") token, err := cache.GetToken(ctx, host, SchemeBearer, attemptedKey) if err == nil { @@ -226,11 +227,11 @@ func (c *Client) Do(originalReq *http.Request) (*http.Response, error) { // merge per-host scopes with generic scopes scopes := append(GetScopesPerHost(ctx, host), GetScopes(ctx)...) - // merge hinted scopes with challenged scopes if paramScope := params["scope"]; paramScope != "" { + // merge hinted scopes with challenged scopes scopes = append(scopes, strings.Split(paramScope, " ")...) - scopes = CleanScopes(scopes) } + scopes = CleanScopes(scopes) key := strings.Join(scopes, " ") // attempt the cache again if there is a scope change