mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
cc65b4d46a
* [Chore] Remove setting provider from secret service Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com> * Add a ShouldBeRedacted func Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com> * Secrets: Make Migrator extensible Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> * Alerting: Fix tests after refactor Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> * Remove commented code no longer used * Fix Wire bindings Co-authored-by: Tania B <yalyna.ts@gmail.com> * Add constructors to secrets * Linting * Undo undesired change --------- Co-authored-by: gamab <gabi.mabs@gmail.com> Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
32 lines
857 B
Go
32 lines
857 B
Go
package defaultprovider
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/services/encryption"
|
|
"github.com/grafana/grafana/pkg/services/secrets"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type grafanaProvider struct {
|
|
cfg *setting.Cfg
|
|
encryption encryption.Internal
|
|
}
|
|
|
|
func New(cfg *setting.Cfg, encryption encryption.Internal) secrets.Provider {
|
|
return grafanaProvider{
|
|
cfg: cfg,
|
|
encryption: encryption,
|
|
}
|
|
}
|
|
|
|
func (p grafanaProvider) Encrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
|
key := p.cfg.SectionWithEnvOverrides("security").Key("secret_key").Value()
|
|
return p.encryption.Encrypt(ctx, blob, key)
|
|
}
|
|
|
|
func (p grafanaProvider) Decrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
|
key := p.cfg.SectionWithEnvOverrides("security").Key("secret_key").Value()
|
|
return p.encryption.Decrypt(ctx, blob, key)
|
|
}
|