Plugins: Add secure JSON fields to plugin setting DTO (#55313)
* add secure JSON fields to plugin setting DTO * add nil pointer fix * adding secureJsonFields to the plugin meta. Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
This commit is contained in:
co-authored by
Marcus Andersson
parent
c10a69c007
commit
b25ea75bac
+20
-13
@@ -170,19 +170,20 @@ func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
dto := &dtos.PluginSetting{
|
||||
Type: string(plugin.Type),
|
||||
Id: plugin.ID,
|
||||
Name: plugin.Name,
|
||||
Info: plugin.Info,
|
||||
Dependencies: plugin.Dependencies,
|
||||
Includes: plugin.Includes,
|
||||
BaseUrl: plugin.BaseURL,
|
||||
Module: plugin.Module,
|
||||
DefaultNavUrl: path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL),
|
||||
State: plugin.State,
|
||||
Signature: plugin.Signature,
|
||||
SignatureType: plugin.SignatureType,
|
||||
SignatureOrg: plugin.SignatureOrg,
|
||||
Type: string(plugin.Type),
|
||||
Id: plugin.ID,
|
||||
Name: plugin.Name,
|
||||
Info: plugin.Info,
|
||||
Dependencies: plugin.Dependencies,
|
||||
Includes: plugin.Includes,
|
||||
BaseUrl: plugin.BaseURL,
|
||||
Module: plugin.Module,
|
||||
DefaultNavUrl: path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL),
|
||||
State: plugin.State,
|
||||
Signature: plugin.Signature,
|
||||
SignatureType: plugin.SignatureType,
|
||||
SignatureOrg: plugin.SignatureOrg,
|
||||
SecureJsonFields: map[string]bool{},
|
||||
}
|
||||
|
||||
if plugin.IsApp() {
|
||||
@@ -202,6 +203,12 @@ func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Respon
|
||||
dto.Enabled = ps.Enabled
|
||||
dto.Pinned = ps.Pinned
|
||||
dto.JsonData = ps.JSONData
|
||||
|
||||
for k, v := range hs.PluginSettings.DecryptedValues(ps) {
|
||||
if len(v) > 0 {
|
||||
dto.SecureJsonFields[k] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update, exists := hs.pluginsUpdateChecker.HasUpdate(c.Req.Context(), plugin.ID)
|
||||
|
||||
Reference in New Issue
Block a user