Skip to content

Commit

Permalink
Slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jul 28, 2023
1 parent 29034d5 commit e8a394e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func NewService(ctx context.Context, p Params) (*Service, error) {
return nil, errors.E(op, err)
}

if err := s.setupSecretStore(ctx, p); err != nil {
if err := s.setupCredentialStore(ctx, p); err != nil {
return nil, errors.E(op, err)
}

Expand Down Expand Up @@ -462,7 +462,7 @@ func newAuthenticator(ctx context.Context, db *db.Database, client *ofgaClient.O
}, nil
}

func (s *Service) setupSecretStore(ctx context.Context, p Params) error {
func (s *Service) setupCredentialStore(ctx context.Context, p Params) error {
const op = errors.Op("newSecretStore")
vs, err := newVaultStore(ctx, p)
if err != nil {
Expand All @@ -471,17 +471,17 @@ func (s *Service) setupSecretStore(ctx context.Context, p Params) error {
}
if vs != nil {
s.jimm.CredentialStore = vs
} else {
// Only enable Postgres storage for secrets if explictly enabled.
if _, ok := os.LookupEnv("INSECURE_SECRET_STORAGE"); ok {
zapctx.Warn(ctx, "using plaintext postgres for secret storage")
s.jimm.CredentialStore = &s.jimm.Database
}
return nil
}
if s.jimm.CredentialStore == nil {
return errors.E(op, "no credential store setup")

// Only enable Postgres storage for secrets if explicitly enabled.
if _, ok := os.LookupEnv("INSECURE_SECRET_STORAGE"); ok {
zapctx.Warn(ctx, "using plaintext postgres for secret storage")
s.jimm.CredentialStore = &s.jimm.Database
return nil
}
return nil

return errors.E(op, "no credential store setup")
}

func newVaultStore(ctx context.Context, p Params) (jimmcreds.CredentialStore, error) {
Expand Down

0 comments on commit e8a394e

Please sign in to comment.