SecretsManager: Add base encryption manager (#107562)
Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com> Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
This commit is contained in:
co-authored by
Michael Mandrus
Matheus Macabu
parent
93c14c52da
commit
4d8678c7f2
@@ -1,6 +1,7 @@
|
||||
package encryption
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -8,6 +9,12 @@ import (
|
||||
|
||||
const UsageInsightsPrefix = "secrets_manager"
|
||||
|
||||
// Provider is a key encryption key provider for envelope encryption
|
||||
type Provider interface {
|
||||
Encrypt(ctx context.Context, blob []byte) ([]byte, error)
|
||||
Decrypt(ctx context.Context, blob []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
type ProviderID string
|
||||
|
||||
func (id ProviderID) Kind() (string, error) {
|
||||
@@ -24,3 +31,15 @@ func (id ProviderID) Kind() (string, error) {
|
||||
func KeyLabel(providerID ProviderID) string {
|
||||
return fmt.Sprintf("%s@%s", time.Now().Format("2006-01-02"), providerID)
|
||||
}
|
||||
|
||||
type ProviderMap map[ProviderID]Provider
|
||||
|
||||
// ProvideThirdPartyProviderMap fulfills the wire dependency needed by the encryption manager in OSS
|
||||
func ProvideThirdPartyProviderMap() ProviderMap {
|
||||
return ProviderMap{}
|
||||
}
|
||||
|
||||
// BackgroundProvider should be implemented for a provider that has a task that needs to be run in the background.
|
||||
type BackgroundProvider interface {
|
||||
Run(ctx context.Context) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user