forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use secrets config for Vault (gopasspw#730)
- Loading branch information
1 parent
d3661d8
commit 00a7fdd
Showing
3 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package vault | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/justwatchcom/gopass/pkg/config/secrets" | ||
) | ||
|
||
func (s *Store) storeSecret(ctx context.Context, key, value string) error { | ||
pw, err := s.agent.Passphrase(ctx, "config.sec", "Please enter passphrase to (un)lock config secrets") | ||
if err != nil { | ||
return err | ||
} | ||
seccfg, err := secrets.New(s.cfgdir, pw) | ||
if err != nil { | ||
return err | ||
} | ||
return seccfg.Set(key, value) | ||
} | ||
|
||
func (s *Store) eraseSecret(ctx context.Context, key string) error { | ||
pw, err := s.agent.Passphrase(ctx, "config.sec", "Please enter passphrase to (un)lock config secrets") | ||
if err != nil { | ||
return err | ||
} | ||
seccfg, err := secrets.New(s.cfgdir, pw) | ||
if err != nil { | ||
return err | ||
} | ||
_ = s.agent.Remove(ctx, key) | ||
return seccfg.Unset(key) | ||
} | ||
|
||
func (s *Store) loadSecret(ctx context.Context, key string) (string, error) { | ||
pw, err := s.agent.Passphrase(ctx, "config.sec", "Please enter passphrase to (un)lock config secrets") | ||
if err != nil { | ||
return "", err | ||
} | ||
seccfg, err := secrets.New(s.cfgdir, pw) | ||
if err != nil { | ||
return "", err | ||
} | ||
t, err := seccfg.Get(key) | ||
if err == nil && t != "" { | ||
return t, nil | ||
} | ||
t, err = s.agent.Passphrase(ctx, key, "Please enter the secret "+key) | ||
if err != nil { | ||
return "", err | ||
} | ||
_ = s.agent.Remove(ctx, key) | ||
err = seccfg.Set(key, t) | ||
return t, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters