mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
live: log error on dashboard subscribe (#35095)
This commit is contained in:
@@ -47,7 +47,7 @@ func (h *DashboardHandler) GetHandlerForPath(path string) (models.ChannelHandler
|
||||
}
|
||||
|
||||
// OnSubscribe for now allows anyone to subscribe to any dashboard
|
||||
func (h *DashboardHandler) OnSubscribe(ctx context.Context, user *models.SignedInUser, e models.SubscribeEvent) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
func (h *DashboardHandler) OnSubscribe(_ context.Context, user *models.SignedInUser, e models.SubscribeEvent) (models.SubscribeReply, backend.SubscribeStreamStatus, error) {
|
||||
parts := strings.Split(e.Path, "/")
|
||||
if parts[0] == "gitops" {
|
||||
// gitops gets all changes for everything, so lets make sure it is an admin user
|
||||
@@ -63,13 +63,13 @@ func (h *DashboardHandler) OnSubscribe(ctx context.Context, user *models.SignedI
|
||||
if len(parts) == 2 && parts[0] == "uid" {
|
||||
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId}
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
logger.Error("Unknown dashboard", "query", query)
|
||||
logger.Error("Error getting dashboard", "query", query, "error", err)
|
||||
return models.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, nil
|
||||
}
|
||||
|
||||
dash := query.Result
|
||||
guardian := guardian.New(dash.Id, user.OrgId, user)
|
||||
if canView, err := guardian.CanView(); err != nil || !canView {
|
||||
guard := guardian.New(dash.Id, user.OrgId, user)
|
||||
if canView, err := guard.CanView(); err != nil || !canView {
|
||||
return models.SubscribeReply{}, backend.SubscribeStreamStatusPermissionDenied, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user