mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
6768c6c059
Removes the public variable setting.SecretKey plus some other ones. Introduces some new functions for creating setting.Cfg.
31 lines
788 B
Go
31 lines
788 B
Go
package migration
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/util"
|
|
)
|
|
|
|
// SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately
|
|
// encrypted.
|
|
type SecureJsonData map[string][]byte
|
|
|
|
var seclogger = log.New("securejsondata")
|
|
|
|
// Decrypt returns map of the same type but where the all the values are decrypted. Opposite of what
|
|
// GetEncryptedJsonData is doing.
|
|
func (s SecureJsonData) Decrypt(secretKey string) map[string]string {
|
|
decrypted := make(map[string]string)
|
|
for key, data := range s {
|
|
decryptedData, err := util.Decrypt(data, secretKey)
|
|
if err != nil {
|
|
seclogger.Error(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
decrypted[key] = string(decryptedData)
|
|
}
|
|
return decrypted
|
|
}
|