Chore: Refactor securedata to remove global encryption calls from dashboard snapshots (#38714)
* Add encryption service * Add tests for encryption service * Inject encryption service into http server * Replace encryption global function usage in login tests * Migrate to Wire * Move Encryption bindings to OSS Wire set * Chore: Refactor securedata to remove global encryption calls from dashboard snapshots * Fix dashboard snapshot tests * Remove no longer user test * Add dashboard snapshots service tests * Refactor service initialization * Set up dashboard snapshots service as a background service Co-authored-by: Tania B <yalyna.ts@gmail.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Tania B
Emil Tullstedt
parent
a4e253bcf9
commit
6cfb640a0b
@@ -3,7 +3,6 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/securedata"
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
)
|
||||
|
||||
@@ -24,18 +23,7 @@ type DashboardSnapshot struct {
|
||||
Updated time.Time
|
||||
|
||||
Dashboard *simplejson.Json
|
||||
DashboardEncrypted securedata.SecureData
|
||||
}
|
||||
|
||||
func (ds *DashboardSnapshot) DashboardJSON() (*simplejson.Json, error) {
|
||||
if ds.DashboardEncrypted != nil {
|
||||
decrypted, err := ds.DashboardEncrypted.Decrypt()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return simplejson.NewJson(decrypted)
|
||||
}
|
||||
return ds.Dashboard, nil
|
||||
DashboardEncrypted []byte
|
||||
}
|
||||
|
||||
// DashboardSnapshotDTO without dashboard map
|
||||
@@ -72,6 +60,8 @@ type CreateDashboardSnapshotCommand struct {
|
||||
OrgId int64 `json:"-"`
|
||||
UserId int64 `json:"-"`
|
||||
|
||||
DashboardEncrypted []byte `json:"-"`
|
||||
|
||||
Result *DashboardSnapshot
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user