@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
grafanaApi "github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/middleware"
@ -18,7 +19,7 @@ import (
const rootUrl = "/api/support-bundles"
func ( s * Service ) registerAPIEndpoints ( routeRegister routing . RouteRegister ) {
func ( s * Service ) registerAPIEndpoints ( httpServer * grafanaApi . HTTPServer , routeRegister routing . RouteRegister ) {
authorize := ac . Middleware ( s . accessControl )
orgRoleMiddleware := middleware . ReqGrafanaAdmin
@ -26,6 +27,14 @@ func (s *Service) registerAPIEndpoints(routeRegister routing.RouteRegister) {
orgRoleMiddleware = middleware . RoleAuth ( roletype . RoleAdmin )
}
supportBundlePageAccess := ac . EvalAny (
ac . EvalPermission ( ActionRead ) ,
ac . EvalPermission ( ActionCreate ) ,
)
routeRegister . Get ( "/support-bundles" , authorize ( orgRoleMiddleware , supportBundlePageAccess ) , httpServer . Index )
routeRegister . Get ( "/support-bundles/create" , authorize ( orgRoleMiddleware , ac . EvalPermission ( ActionCreate ) ) , httpServer . Index )
routeRegister . Group ( rootUrl , func ( subrouter routing . RouteRegister ) {
subrouter . Get ( "/" , authorize ( orgRoleMiddleware ,
ac . EvalPermission ( ActionRead ) ) , routing . Wrap ( s . handleList ) )
@ -81,11 +90,11 @@ func (s *Service) handleDownload(ctx *models.ReqContext) response.Response {
uid := web . Params ( ctx . Req ) [ ":uid" ]
bundle , err := s . get ( ctx . Req . Context ( ) , uid )
if err != nil {
return response . Redirect ( "/admin/ support-bundles" )
return response . Redirect ( "/support-bundles" )
}
if bundle . State != supportbundles . StateComplete {
return response . Redirect ( "/admin/ support-bundles" )
return response . Redirect ( "/support-bundles" )
}
ctx . Resp . Header ( ) . Set ( "Content-Type" , "application/tar+gzip" )