mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Don't filter datasources from FrontendSettings in a public dashboard (#57208)
* add filter skip to avoid issues with RBAC * update comment
This commit is contained in:
parent
69bfd923be
commit
2a8a82e2af
@ -215,21 +215,23 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
|
|||||||
|
|
||||||
func (hs *HTTPServer) getFSDataSources(c *models.ReqContext, enabledPlugins EnabledPlugins) (map[string]plugins.DataSourceDTO, error) {
|
func (hs *HTTPServer) getFSDataSources(c *models.ReqContext, enabledPlugins EnabledPlugins) (map[string]plugins.DataSourceDTO, error) {
|
||||||
orgDataSources := make([]*datasources.DataSource, 0)
|
orgDataSources := make([]*datasources.DataSource, 0)
|
||||||
|
|
||||||
if c.OrgID != 0 {
|
if c.OrgID != 0 {
|
||||||
query := datasources.GetDataSourcesQuery{OrgId: c.OrgID, DataSourceLimit: hs.Cfg.DataSourceLimit}
|
query := datasources.GetDataSourcesQuery{OrgId: c.OrgID, DataSourceLimit: hs.Cfg.DataSourceLimit}
|
||||||
err := hs.DataSourcesService.GetDataSources(c.Req.Context(), &query)
|
err := hs.DataSourcesService.GetDataSources(c.Req.Context(), &query)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
filtered, err := hs.filterDatasourcesByQueryPermission(c.Req.Context(), c.SignedInUser, query.Result)
|
if c.IsPublicDashboardView {
|
||||||
if err != nil {
|
// If RBAC is enabled, it will filter out all datasources for a public user, so we need to skip it
|
||||||
return nil, err
|
orgDataSources = query.Result
|
||||||
|
} else {
|
||||||
|
filtered, err := hs.filterDatasourcesByQueryPermission(c.Req.Context(), c.SignedInUser, query.Result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
orgDataSources = filtered
|
||||||
}
|
}
|
||||||
|
|
||||||
orgDataSources = filtered
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSources := make(map[string]plugins.DataSourceDTO)
|
dataSources := make(map[string]plugins.DataSourceDTO)
|
||||||
|
Loading…
Reference in New Issue
Block a user