mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Chore: Move default encryption provider to kmsproviders package (#43331)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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 {
|
||||
settings setting.Provider
|
||||
encryption encryption.Internal
|
||||
}
|
||||
|
||||
func New(settings setting.Provider, encryption encryption.Internal) secrets.Provider {
|
||||
return grafanaProvider{
|
||||
settings: settings,
|
||||
encryption: encryption,
|
||||
}
|
||||
}
|
||||
|
||||
func (p grafanaProvider) Encrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
||||
key := p.settings.KeyValue("security", "secret_key").Value()
|
||||
return p.encryption.Encrypt(ctx, blob, key)
|
||||
}
|
||||
|
||||
func (p grafanaProvider) Decrypt(ctx context.Context, blob []byte) ([]byte, error) {
|
||||
key := p.settings.KeyValue("security", "secret_key").Value()
|
||||
return p.encryption.Decrypt(ctx, blob, key)
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package osskmsproviders
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/services/encryption"
|
||||
"github.com/grafana/grafana/pkg/services/kmsproviders"
|
||||
grafana "github.com/grafana/grafana/pkg/services/kmsproviders/defaultprovider"
|
||||
"github.com/grafana/grafana/pkg/services/secrets"
|
||||
grafana "github.com/grafana/grafana/pkg/services/secrets/defaultprovider"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user