Skip to content

Commit 1f57153

Browse files
committed
keychain/windows: support more system errors and don't ignore unmapped error
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
1 parent 79c7129 commit 1f57153

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

store/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/keybase/dbus v0.0.0-20220506165403-5aa21ea2c23a
1111
github.com/keybase/go-keychain v0.0.1
1212
github.com/stretchr/testify v1.10.0
13+
golang.org/x/sys v0.29.0
1314
golang.org/x/text v0.21.0
1415
)
1516

@@ -19,7 +20,6 @@ require (
1920
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
2021
github.com/pmezard/go-difflib v1.0.0 // indirect
2122
golang.org/x/crypto v0.32.0 // indirect
22-
golang.org/x/sys v0.29.0 // indirect
2323
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
2424
gopkg.in/yaml.v3 v3.0.1 // indirect
2525
)

store/keychain/keychain_windows.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/danieljoos/wincred"
1010
"github.com/docker/secrets-engine/store"
11+
"golang.org/x/sys/windows"
1112
"golang.org/x/text/encoding/unicode"
1213
"golang.org/x/text/transform"
1314
)
@@ -17,6 +18,8 @@ var (
1718
ErrInvalidCredentialFlags = errors.New("an invalid flag was specified for the flags parameter")
1819
ErrInvalidCredentialParameter = errors.New("protected field does not match provided value for an existing credential")
1920
ErrNoLogonSession = errors.New("logon session does not exist or there is no credential set associated with this logon session")
21+
sysErrInvalidCredentialFlags = windows.Errno(windows.ERROR_INVALID_FLAGS)
22+
sysErrNoSuchLogonSession = windows.Errno(windows.ERROR_NO_SUCH_LOGON_SESSION)
2023
)
2124

2225
func (k *keychainStore[T]) Delete(ctx context.Context, id store.ID) error {
@@ -179,6 +182,10 @@ func mapWindowsCredentialError(err error) error {
179182
return ErrCredentialBadUsername
180183
case wincred.ErrInvalidParameter:
181184
return ErrInvalidCredentialParameter
185+
case sysErrInvalidCredentialFlags:
186+
return ErrInvalidCredentialFlags
187+
case sysErrNoSuchLogonSession:
188+
return ErrNoLogonSession
182189
}
183-
return nil
190+
return err
184191
}

0 commit comments

Comments
 (0)