Skip to content

Commit

Permalink
feat: support delete all credentials on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Sep 11, 2024
1 parent e0a78dd commit e67f16a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/lipgloss v0.12.1
github.com/containers/common v0.59.2
github.com/danieljoos/wincred v1.2.1
github.com/deepmap/oapi-codegen/v2 v2.2.0
github.com/docker/cli v26.1.5+incompatible
github.com/docker/docker v26.1.5+incompatible
Expand Down Expand Up @@ -114,7 +115,6 @@ require (
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/daixiang0/gci v0.13.4 // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
Expand Down
25 changes: 25 additions & 0 deletions internal/utils/credentials/store_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build windows

package credentials

import (
"github.com/danieljoos/wincred"
"github.com/go-errors/errors"
)

func DeleteAll() error {
if err := assertKeyringSupported(); err != nil {
return err
}
creds, err := wincred.FilteredList(namespace + ":")
if err != nil {
return errors.Errorf("failed to list credentials: %w", err)
}
for _, c := range creds {
gc := wincred.GenericCredential{Credential: *c}
if err := gc.Delete(); err != nil {
return errors.Errorf("failed to delete all credentials: %w", err)
}
}
return nil
}

0 comments on commit e67f16a

Please sign in to comment.