1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-13 16:01:28 +05:30

[Windows] align get with list behavior

Avoiding to get unlabelled credentials

Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
This commit is contained in:
Simon Ferquel
2017-03-16 18:16:37 +01:00
parent 120e37f15d
commit 51c78cdc14
+10 -2
View File
@@ -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.