|
|
@ -47,7 +47,7 @@ func (h *DashboardHandler) GetHandlerForPath(path string) (models.ChannelHandler |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// OnSubscribe for now allows anyone to subscribe to any dashboard
|
|
|
|
// 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, "/") |
|
|
|
parts := strings.Split(e.Path, "/") |
|
|
|
if parts[0] == "gitops" { |
|
|
|
if parts[0] == "gitops" { |
|
|
|
// gitops gets all changes for everything, so lets make sure it is an admin user
|
|
|
|
// 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" { |
|
|
|
if len(parts) == 2 && parts[0] == "uid" { |
|
|
|
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId} |
|
|
|
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId} |
|
|
|
if err := bus.Dispatch(&query); err != nil { |
|
|
|
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 |
|
|
|
return models.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dash := query.Result |
|
|
|
dash := query.Result |
|
|
|
guardian := guardian.New(dash.Id, user.OrgId, user) |
|
|
|
guard := guardian.New(dash.Id, user.OrgId, user) |
|
|
|
if canView, err := guardian.CanView(); err != nil || !canView { |
|
|
|
if canView, err := guard.CanView(); err != nil || !canView { |
|
|
|
return models.SubscribeReply{}, backend.SubscribeStreamStatusPermissionDenied, nil |
|
|
|
return models.SubscribeReply{}, backend.SubscribeStreamStatusPermissionDenied, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|