Skip to content

Commit

Permalink
revert: "fix: call op serially to avoid multiple authorization prom…
Browse files Browse the repository at this point in the history
…pts (#1939)

Loading passwords this way took so long that deploys started failing.
This reverts commit b5fbf19.
  • Loading branch information
matt2e authored Jul 2, 2024
1 parent 4cf3adf commit 382ba8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions common/configuration/1password_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/url"
"regexp"
"strings"
"sync"

"github.com/kballard/go-shellquote"

Expand All @@ -21,23 +20,16 @@ import (
// 1Password vaults via the "op" command line tool.
type OnePasswordProvider struct {
Vault string

// When 1Password is locked we don't want to bring up multiple prompts.
// By coordinating with this lock we can ensure that only one prompt is shown.
lock sync.Mutex
}

func (*OnePasswordProvider) Role() Secrets { return Secrets{} }
func (o *OnePasswordProvider) Key() string { return "op" }
func (o *OnePasswordProvider) Delete(ctx context.Context, ref Ref) error {
func (OnePasswordProvider) Role() Secrets { return Secrets{} }
func (o OnePasswordProvider) Key() string { return "op" }
func (o OnePasswordProvider) Delete(ctx context.Context, ref Ref) error {
return nil
}

// Load returns the secret stored in 1password.
func (o *OnePasswordProvider) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error) {
o.lock.Lock()
defer o.lock.Unlock()

func (o OnePasswordProvider) Load(ctx context.Context, ref Ref, key *url.URL) ([]byte, error) {
if err := checkOpBinary(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -69,10 +61,7 @@ var vaultRegex = regexp.MustCompile(`^[a-zA-Z0-9_\-.]+$`)
//
// op does not support "create or update" as a single command. Neither does it support specifying an ID on create.
// Because of this, we need check if the item exists before creating it, and update it if it does.
func (o *OnePasswordProvider) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error) {
o.lock.Lock()
defer o.lock.Unlock()

func (o OnePasswordProvider) Store(ctx context.Context, ref Ref, value []byte) (*url.URL, error) {
if err := checkOpBinary(); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion common/configuration/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ func NewSecretsManager(ctx context.Context, router Router[Secrets], opVault stri
InlineProvider[Secrets]{},
EnvarProvider[Secrets]{},
KeychainProvider{},
&OnePasswordProvider{Vault: opVault},
OnePasswordProvider{Vault: opVault},
})
}

0 comments on commit 382ba8b

Please sign in to comment.