From 51c78cdc146bf95b4a2b7ea4244685facee45c04 Mon Sep 17 00:00:00 2001 From: Simon Ferquel Date: Thu, 16 Mar 2017 18:16:37 +0100 Subject: [PATCH] [Windows] align get with list behavior Avoiding to get unlabelled credentials Signed-off-by: Simon Ferquel --- wincred/wincred_windows.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wincred/wincred_windows.go b/wincred/wincred_windows.go index bf00551..dcfa123 100644 --- a/wincred/wincred_windows.go +++ b/wincred/wincred_windows.go @@ -2,9 +2,10 @@ package wincred import ( "bytes" + "strings" + winc "github.com/danieljoos/wincred" "github.com/docker/docker-credential-helpers/credentials" - "strings" ) // Wincred handles secrets using the Windows credential service. @@ -39,7 +40,14 @@ func (h Wincred) Get(serverURL string) (string, string, error) { if g == nil { return "", "", credentials.NewErrCredentialsNotFound() } - return g.UserName, string(g.CredentialBlob), nil + for _, attr := range g.Attributes { + if strings.Compare(attr.Keyword, "label") == 0 && + bytes.Compare(attr.Value, []byte(credentials.CredsLabel)) == 0 { + + return g.UserName, string(g.CredentialBlob), nil + } + } + return "", "", credentials.NewErrCredentialsNotFound() } // List returns the stored URLs and corresponding usernames for a given credentials label.