The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/setting/setting_secrets_manager.go

37 lines
1.3 KiB

package setting
import (
"strings"
)
const (
ProviderPrefix = "secrets_manager.encryption."
MisconfiguredProvider = "misconfigured"
)
type SecretsManagerSettings struct {
CurrentEncryptionProvider string
// ConfiguredKMSProviders is a map of KMS providers found in the config file. The keys are in the format of <provider>.<keyName>, and the values are a map of the properties in that section
// In OSS, the provider type can only be "secret_key". In Enterprise, it can additionally be one of: "aws_kms", "azure_keyvault", "google_kms", "hashicorp_vault"
ConfiguredKMSProviders map[string]map[string]string
}
func (cfg *Cfg) readSecretsManagerSettings() {
secretsMgmt := cfg.Raw.Section("secrets_manager")
cfg.SecretsManagement.CurrentEncryptionProvider = secretsMgmt.Key("encryption_provider").MustString(MisconfiguredProvider)
// Extract available KMS providers from configuration sections
providers := make(map[string]map[string]string)
for _, section := range cfg.Raw.Sections() {
sectionName := section.Name()
if strings.HasPrefix(sectionName, ProviderPrefix) {
// Extract the provider name (everything after the prefix)
providerName := strings.TrimPrefix(sectionName, ProviderPrefix)
if providerName != "" {
providers[providerName] = section.KeysHash()
}
}
}
cfg.SecretsManagement.ConfiguredKMSProviders = providers
}