mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LBAC for datasources: Override lbac rules if present when updating via datasources endpoints (#94608)
bloc updates to datasources
This commit is contained in:
parent
573b40ab98
commit
a46ff09bf9
@ -205,6 +205,8 @@ type UpdateDataSourceCommand struct {
|
|||||||
EncryptedSecureJsonData map[string][]byte `json:"-"`
|
EncryptedSecureJsonData map[string][]byte `json:"-"`
|
||||||
UpdateSecretFn UpdateSecretFn `json:"-"`
|
UpdateSecretFn UpdateSecretFn `json:"-"`
|
||||||
IgnoreOldSecureJsonData bool `json:"-"`
|
IgnoreOldSecureJsonData bool `json:"-"`
|
||||||
|
|
||||||
|
OnlyUpdateLBACRulesFromAPI bool `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteDataSourceCommand will delete a DataSource based on OrgID as well as the UID (preferred), ID, or Name.
|
// DeleteDataSourceCommand will delete a DataSource based on OrgID as well as the UID (preferred), ID, or Name.
|
||||||
|
@ -534,6 +534,24 @@ func (s *Service) UpdateDataSource(ctx context.Context, cmd *datasources.UpdateD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: we will eventually remove this check for moving the resource to it's separate API
|
||||||
|
if s.features != nil && s.features.IsEnabled(ctx, featuremgmt.FlagTeamHttpHeaders) && !cmd.OnlyUpdateLBACRulesFromAPI {
|
||||||
|
s.logger.Debug("Overriding LBAC rules with stored ones",
|
||||||
|
"reason", "update_lbac_rules_from_datasource_api",
|
||||||
|
"action", "use_updateLBACRules_API",
|
||||||
|
"datasource_id", dataSource.ID,
|
||||||
|
"datasource_uid", dataSource.UID)
|
||||||
|
|
||||||
|
if dataSource.JsonData != nil {
|
||||||
|
previousRules := dataSource.JsonData.Get("teamHttpHeaders")
|
||||||
|
if previousRules == nil {
|
||||||
|
cmd.JsonData.Del("teamHttpHeaders")
|
||||||
|
} else {
|
||||||
|
cmd.JsonData.Set("teamHttpHeaders", previousRules)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cmd.Name != "" && cmd.Name != dataSource.Name {
|
if cmd.Name != "" && cmd.Name != dataSource.Name {
|
||||||
query := &datasources.GetDataSourceQuery{
|
query := &datasources.GetDataSourceQuery{
|
||||||
Name: cmd.Name,
|
Name: cmd.Name,
|
||||||
|
Loading…
Reference in New Issue
Block a user