| 
									
										
										
										
											2020-12-15 16:32:06 +08:00
										 |  |  | // Package api contains API logic.
 | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | package api | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2020-12-09 23:22:24 +08:00
										 |  |  | 	"time" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 14:37:28 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/api/frontendlogging" | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/api/routing" | 
					
						
							| 
									
										
										
										
											2020-12-15 16:32:06 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/infra/log" | 
					
						
							| 
									
										
										
										
											2015-02-05 17:37:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/middleware" | 
					
						
							| 
									
										
										
										
											2019-06-26 14:47:03 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/models" | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	ac "github.com/grafana/grafana/pkg/services/accesscontrol" | 
					
						
							| 
									
										
										
										
											2022-03-10 00:57:50 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/dashboards" | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/services/datasources" | 
					
						
							| 
									
										
										
										
											2022-01-27 01:44:20 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/featuremgmt" | 
					
						
							| 
									
										
										
										
											2022-04-14 19:40:15 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/serviceaccounts" | 
					
						
							| 
									
										
										
										
											2022-04-07 00:24:33 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/web" | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-15 16:32:06 +08:00
										 |  |  | var plog = log.New("api") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-28 16:36:57 +08:00
										 |  |  | // registerRoutes registers all API HTTP routes.
 | 
					
						
							| 
									
										
										
										
											2018-03-23 05:13:46 +08:00
										 |  |  | func (hs *HTTPServer) registerRoutes() { | 
					
						
							| 
									
										
										
										
											2021-03-16 23:46:34 +08:00
										 |  |  | 	reqNoAuth := middleware.NoAuth() | 
					
						
							| 
									
										
										
										
											2018-10-11 18:36:04 +08:00
										 |  |  | 	reqSignedIn := middleware.ReqSignedIn | 
					
						
							| 
									
										
										
										
											2021-06-15 00:02:05 +08:00
										 |  |  | 	reqNotSignedIn := middleware.ReqNotSignedIn | 
					
						
							| 
									
										
										
										
											2021-02-28 01:04:28 +08:00
										 |  |  | 	reqSignedInNoAnonymous := middleware.ReqSignedInNoAnonymous | 
					
						
							| 
									
										
										
										
											2018-10-11 18:36:04 +08:00
										 |  |  | 	reqGrafanaAdmin := middleware.ReqGrafanaAdmin | 
					
						
							|  |  |  | 	reqEditorRole := middleware.ReqEditorRole | 
					
						
							|  |  |  | 	reqOrgAdmin := middleware.ReqOrgAdmin | 
					
						
							| 
									
										
										
										
											2022-02-17 23:59:09 +08:00
										 |  |  | 	reqOrgAdminFolderAdminOrTeamAdmin := middleware.OrgAdminFolderAdminOrTeamAdmin(hs.SQLStore) | 
					
						
							| 
									
										
										
										
											2022-02-09 20:44:38 +08:00
										 |  |  | 	reqCanAccessTeams := middleware.AdminOrEditorAndFeatureEnabled(hs.Cfg.EditorsCanAdmin) | 
					
						
							| 
									
										
										
										
											2020-12-11 18:44:44 +08:00
										 |  |  | 	reqSnapshotPublicModeOrSignedIn := middleware.SnapshotPublicModeOrSignedIn(hs.Cfg) | 
					
						
							| 
									
										
										
										
											2020-12-16 02:09:04 +08:00
										 |  |  | 	redirectFromLegacyPanelEditURL := middleware.RedirectFromLegacyPanelEditURL(hs.Cfg) | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 	authorize := ac.Middleware(hs.AccessControl) | 
					
						
							|  |  |  | 	authorizeInOrg := ac.AuthorizeInOrgMiddleware(hs.AccessControl, hs.SQLStore) | 
					
						
							| 
									
										
										
										
											2019-02-12 04:12:01 +08:00
										 |  |  | 	quota := middleware.Quota(hs.QuotaService) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-27 19:41:58 +08:00
										 |  |  | 	r := hs.RouteRegister | 
					
						
							| 
									
										
										
										
											2016-08-29 20:45:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 	// not logged in views
 | 
					
						
							| 
									
										
										
										
											2019-01-15 22:15:52 +08:00
										 |  |  | 	r.Get("/logout", hs.Logout) | 
					
						
							| 
									
										
										
										
											2021-10-06 18:52:27 +08:00
										 |  |  | 	r.Post("/login", quota("session"), routing.Wrap(hs.LoginPost)) | 
					
						
							| 
									
										
										
										
											2019-01-15 22:15:52 +08:00
										 |  |  | 	r.Get("/login/:name", quota("session"), hs.OAuthLogin) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/login", hs.LoginView) | 
					
						
							|  |  |  | 	r.Get("/invite/:code", hs.Index) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 	// authed views
 | 
					
						
							| 
									
										
										
										
											2020-11-11 06:36:35 +08:00
										 |  |  | 	r.Get("/", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2021-02-28 01:04:28 +08:00
										 |  |  | 	r.Get("/profile/", reqSignedInNoAnonymous, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/profile/password", reqSignedInNoAnonymous, hs.Index) | 
					
						
							| 
									
										
										
										
											2020-11-11 06:36:35 +08:00
										 |  |  | 	r.Get("/.well-known/change-password", redirectToChangePassword) | 
					
						
							| 
									
										
										
										
											2021-02-28 01:04:28 +08:00
										 |  |  | 	r.Get("/profile/switch-org/:id", reqSignedInNoAnonymous, hs.ChangeActiveOrgAndRedirectToHome) | 
					
						
							| 
									
										
										
										
											2021-11-18 21:10:38 +08:00
										 |  |  | 	r.Get("/org/", authorize(reqOrgAdmin, orgPreferencesAccessEvaluator), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 	r.Get("/org/new", authorizeInOrg(reqGrafanaAdmin, ac.UseGlobalOrg, orgsCreateAccessEvaluator), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 	r.Get("/datasources/", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/datasources/new", authorize(reqOrgAdmin, datasources.NewPageAccess), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/datasources/edit/*", authorize(reqOrgAdmin, datasources.EditPageAccess), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-01-13 21:40:32 +08:00
										 |  |  | 	r.Get("/org/users", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRead)), hs.Index) | 
					
						
							| 
									
										
										
										
											2019-03-04 22:51:18 +08:00
										 |  |  | 	r.Get("/org/users/new", reqOrgAdmin, hs.Index) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	r.Get("/org/users/invite", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionUsersCreate)), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-02-04 00:49:39 +08:00
										 |  |  | 	r.Get("/org/teams", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsRead)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/org/teams/edit/*", authorize(reqCanAccessTeams, teamsEditAccessEvaluator), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/org/teams/new", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsCreate)), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-04-14 19:40:15 +08:00
										 |  |  | 	r.Get("/org/serviceaccounts", authorize(reqOrgAdmin, ac.EvalPermission(serviceaccounts.ActionRead)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/org/serviceaccounts/:serviceAccountId", authorize(reqOrgAdmin, ac.EvalPermission(serviceaccounts.ActionRead)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/org/apikeys/", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionAPIKeyRead)), hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/dashboard/import/", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/configuration", reqGrafanaAdmin, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin", reqGrafanaAdmin, hs.Index) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	r.Get("/admin/settings", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin/users", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead, ac.ScopeGlobalUsersAll)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin/users/create", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersCreate)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin/users/edit/:id", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead)), hs.Index) | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 	r.Get("/admin/orgs", authorizeInOrg(reqGrafanaAdmin, ac.UseGlobalOrg, orgsAccessEvaluator), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin/orgs/edit/:id", authorizeInOrg(reqGrafanaAdmin, ac.UseGlobalOrg, orgsAccessEvaluator), hs.Index) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	r.Get("/admin/stats", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionServerStatsRead)), hs.Index) | 
					
						
							|  |  |  | 	r.Get("/admin/ldap", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPStatusRead)), hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/styleguide", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:09:55 +08:00
										 |  |  | 	r.Get("/live", reqGrafanaAdmin, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/live/pipeline", reqGrafanaAdmin, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/live/cloud", reqGrafanaAdmin, hs.Index) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/plugins", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2019-05-03 01:15:39 +08:00
										 |  |  | 	r.Get("/plugins/:id/", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/plugins/:id/edit", reqSignedIn, hs.Index) // deprecated
 | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/plugins/:id/page/:page", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2019-05-03 01:15:39 +08:00
										 |  |  | 	r.Get("/a/:id/*", reqSignedIn, hs.Index) // App Root Page
 | 
					
						
							| 
									
										
										
										
											2021-07-05 16:24:14 +08:00
										 |  |  | 	r.Get("/a/:id", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-17 18:51:41 +08:00
										 |  |  | 	r.Get("/d/:uid/:slug", reqSignedIn, redirectFromLegacyPanelEditURL, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/d/:uid", reqSignedIn, redirectFromLegacyPanelEditURL, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/dashboard/script/*", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2020-11-11 06:36:35 +08:00
										 |  |  | 	r.Get("/dashboard/new", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/dashboard-solo/snapshot/*", hs.Index) | 
					
						
							|  |  |  | 	r.Get("/d-solo/:uid/:slug", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2019-10-15 00:21:44 +08:00
										 |  |  | 	r.Get("/d-solo/:uid", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/dashboard-solo/script/*", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/import/dashboard", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/dashboards/", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/dashboards/*", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2020-10-14 18:48:48 +08:00
										 |  |  | 	r.Get("/goto/:uid", reqSignedIn, hs.redirectFromShortURL, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-02 20:43:12 +08:00
										 |  |  | 	r.Get("/explore", authorize(func(c *models.ReqContext) { | 
					
						
							|  |  |  | 		if f, ok := reqSignedIn.(func(c *models.ReqContext)); ok { | 
					
						
							|  |  |  | 			f(c) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		middleware.EnsureEditorOrViewerCanEdit(c) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	}, ac.EvalPermission(ac.ActionDatasourcesExplore)), hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	r.Get("/playlists/", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/playlists/*", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2021-05-17 16:15:17 +08:00
										 |  |  | 	r.Get("/alerting/", reqSignedIn, hs.Index) | 
					
						
							|  |  |  | 	r.Get("/alerting/*", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2015-12-22 18:07:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 	// sign up
 | 
					
						
							| 
									
										
										
										
											2020-09-07 23:24:46 +08:00
										 |  |  | 	r.Get("/verify", hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/signup", hs.Index) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 	r.Get("/api/user/signup/options", routing.Wrap(GetSignUpOptions)) | 
					
						
							| 
									
										
										
										
											2022-01-27 17:33:02 +08:00
										 |  |  | 	r.Post("/api/user/signup", quota("user"), routing.Wrap(hs.SignUp)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 	r.Post("/api/user/signup/step2", routing.Wrap(hs.SignUpStep2)) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 21:52:49 +08:00
										 |  |  | 	// invited
 | 
					
						
							| 
									
										
										
										
											2022-02-01 00:24:52 +08:00
										 |  |  | 	r.Get("/api/user/invite/:code", routing.Wrap(hs.GetInviteInfoByCode)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 	r.Post("/api/user/invite/complete", routing.Wrap(hs.CompleteInvite)) | 
					
						
							| 
									
										
										
										
											2015-07-20 21:52:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-08 16:57:01 +08:00
										 |  |  | 	// reset password
 | 
					
						
							| 
									
										
										
										
											2021-06-15 00:02:05 +08:00
										 |  |  | 	r.Get("/user/password/send-reset-email", reqNotSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/user/password/reset", hs.Index) | 
					
						
							| 
									
										
										
										
											2015-06-08 16:57:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-03 17:33:46 +08:00
										 |  |  | 	r.Post("/api/user/password/send-reset-email", routing.Wrap(hs.SendResetPasswordEmail)) | 
					
						
							|  |  |  | 	r.Post("/api/user/password/reset", routing.Wrap(hs.ResetPassword)) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-21 20:53:16 +08:00
										 |  |  | 	// dashboard snapshots
 | 
					
						
							| 
									
										
										
										
											2021-03-16 23:46:34 +08:00
										 |  |  | 	r.Get("/dashboard/snapshot/*", reqNoAuth, hs.Index) | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	r.Get("/dashboard/snapshots/", reqSignedIn, hs.Index) | 
					
						
							| 
									
										
										
										
											2015-03-27 03:34:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-05 00:37:07 +08:00
										 |  |  | 	// api renew session based on cookie
 | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 	r.Get("/api/login/ping", quota("session"), routing.Wrap(hs.LoginAPIPing)) | 
					
						
							| 
									
										
										
										
											2015-04-07 15:25:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-21 21:17:23 +08:00
										 |  |  | 	// expose plugin file system assets
 | 
					
						
							| 
									
										
										
										
											2021-09-08 14:49:05 +08:00
										 |  |  | 	r.Get("/public/plugins/:pluginId/*", hs.getPluginAssets) | 
					
						
							| 
									
										
										
										
											2021-04-21 21:17:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-08 20:38:43 +08:00
										 |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagSwaggerUi) { | 
					
						
							|  |  |  | 		r.Get("/swagger-ui", swaggerUI) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 	// authed api
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 	r.Group("/api", func(apiRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2015-05-19 17:47:14 +08:00
										 |  |  | 		// user (signed in)
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/user", func(userRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-01-05 16:59:17 +08:00
										 |  |  | 			userRoute.Get("/", routing.Wrap(hs.GetSignedInUser)) | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			userRoute.Put("/", routing.Wrap(hs.UpdateSignedInUser)) | 
					
						
							|  |  |  | 			userRoute.Post("/using/:id", routing.Wrap(hs.UserSetUsingOrg)) | 
					
						
							|  |  |  | 			userRoute.Get("/orgs", routing.Wrap(hs.GetSignedInUserOrgList)) | 
					
						
							|  |  |  | 			userRoute.Get("/teams", routing.Wrap(hs.GetSignedInUserTeamList)) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-03 23:52:19 +08:00
										 |  |  | 			userRoute.Get("/stars", routing.Wrap(hs.GetStars)) | 
					
						
							| 
									
										
										
										
											2022-01-24 18:52:35 +08:00
										 |  |  | 			userRoute.Post("/stars/dashboard/:id", routing.Wrap(hs.StarDashboard)) | 
					
						
							|  |  |  | 			userRoute.Delete("/stars/dashboard/:id", routing.Wrap(hs.UnstarDashboard)) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			userRoute.Put("/password", routing.Wrap(hs.ChangeUserPassword)) | 
					
						
							| 
									
										
										
										
											2022-02-03 16:20:20 +08:00
										 |  |  | 			userRoute.Get("/quotas", routing.Wrap(hs.GetUserQuotas)) | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			userRoute.Put("/helpflags/:id", routing.Wrap(hs.SetHelpFlag)) | 
					
						
							| 
									
										
										
										
											2016-11-09 17:41:39 +08:00
										 |  |  | 			// For dev purpose
 | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			userRoute.Get("/helpflags/clear", routing.Wrap(hs.ClearHelpFlags)) | 
					
						
							| 
									
										
										
										
											2016-04-03 04:54:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-02 20:41:45 +08:00
										 |  |  | 			userRoute.Get("/preferences", routing.Wrap(hs.GetUserPreferences)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			userRoute.Put("/preferences", routing.Wrap(hs.UpdateUserPreferences)) | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | 			userRoute.Patch("/preferences", routing.Wrap(hs.PatchUserPreferences)) | 
					
						
							| 
									
										
										
										
											2019-03-08 22:15:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 			userRoute.Get("/auth-tokens", routing.Wrap(hs.GetUserAuthTokens)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			userRoute.Post("/revoke-auth-token", routing.Wrap(hs.RevokeUserAuthToken)) | 
					
						
							| 
									
										
										
										
											2021-02-28 01:04:28 +08:00
										 |  |  | 		}, reqSignedInNoAnonymous) | 
					
						
							| 
									
										
										
										
											2015-01-20 01:01:04 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/users", func(usersRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-22 19:48:46 +08:00
										 |  |  | 			userIDScope := ac.Scope("global.users", "id", ac.Parameter(":id")) | 
					
						
							| 
									
										
										
										
											2022-05-13 15:26:34 +08:00
										 |  |  | 			usersRoute.Get("/", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead)), routing.Wrap(hs.searchUsersService.SearchUsers)) | 
					
						
							|  |  |  | 			usersRoute.Get("/search", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead)), routing.Wrap(hs.searchUsersService.SearchUsersWithPaging)) | 
					
						
							| 
									
										
										
										
											2022-01-05 16:59:17 +08:00
										 |  |  | 			usersRoute.Get("/:id", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead, userIDScope)), routing.Wrap(hs.GetUserByID)) | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			usersRoute.Get("/:id/teams", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersTeamRead, userIDScope)), routing.Wrap(hs.GetUserTeams)) | 
					
						
							|  |  |  | 			usersRoute.Get("/:id/orgs", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead, userIDScope)), routing.Wrap(hs.GetUserOrgList)) | 
					
						
							| 
									
										
										
										
											2017-01-31 13:25:55 +08:00
										 |  |  | 			// query parameters /users/lookup?loginOrEmail=admin@example.com
 | 
					
						
							| 
									
										
										
										
											2022-01-27 03:24:05 +08:00
										 |  |  | 			usersRoute.Get("/lookup", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead, ac.ScopeGlobalUsersAll)), routing.Wrap(hs.GetUserByLoginOrEmail)) | 
					
						
							|  |  |  | 			usersRoute.Put("/:id", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersWrite, userIDScope)), routing.Wrap(hs.UpdateUser)) | 
					
						
							|  |  |  | 			usersRoute.Post("/:id/using/:orgId", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersWrite, userIDScope)), routing.Wrap(hs.UpdateUserActiveOrg)) | 
					
						
							| 
									
										
										
										
											2021-04-14 22:31:27 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-05-18 23:28:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 23:25:45 +08:00
										 |  |  | 		// team (admin permission required)
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/teams", func(teamsRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-01-26 22:48:41 +08:00
										 |  |  | 			teamsRoute.Post("/", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsCreate)), routing.Wrap(hs.CreateTeam)) | 
					
						
							| 
									
										
										
										
											2022-01-27 23:16:44 +08:00
										 |  |  | 			teamsRoute.Put("/:teamId", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsWrite, ac.ScopeTeamsID)), routing.Wrap(hs.UpdateTeam)) | 
					
						
							|  |  |  | 			teamsRoute.Delete("/:teamId", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsDelete, ac.ScopeTeamsID)), routing.Wrap(hs.DeleteTeamByID)) | 
					
						
							| 
									
										
										
										
											2022-01-26 22:48:41 +08:00
										 |  |  | 			teamsRoute.Get("/:teamId/members", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsPermissionsRead, ac.ScopeTeamsID)), routing.Wrap(hs.GetTeamMembers)) | 
					
						
							|  |  |  | 			teamsRoute.Post("/:teamId/members", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsPermissionsWrite, ac.ScopeTeamsID)), routing.Wrap(hs.AddTeamMember)) | 
					
						
							|  |  |  | 			teamsRoute.Put("/:teamId/members/:userId", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsPermissionsWrite, ac.ScopeTeamsID)), routing.Wrap(hs.UpdateTeamMember)) | 
					
						
							|  |  |  | 			teamsRoute.Delete("/:teamId/members/:userId", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsPermissionsWrite, ac.ScopeTeamsID)), routing.Wrap(hs.RemoveTeamMember)) | 
					
						
							| 
									
										
										
										
											2022-01-28 19:17:54 +08:00
										 |  |  | 			teamsRoute.Get("/:teamId/preferences", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsRead, ac.ScopeTeamsID)), routing.Wrap(hs.GetTeamPreferences)) | 
					
						
							|  |  |  | 			teamsRoute.Put("/:teamId/preferences", authorize(reqCanAccessTeams, ac.EvalPermission(ac.ActionTeamsWrite, ac.ScopeTeamsID)), routing.Wrap(hs.UpdateTeamPreferences)) | 
					
						
							| 
									
										
										
										
											2022-01-11 01:05:53 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2017-04-10 07:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 20:08:23 +08:00
										 |  |  | 		// team without requirement of user to be org admin
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/teams", func(teamsRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-09 23:17:31 +08:00
										 |  |  | 			teamsRoute.Get("/:teamId", authorize(reqSignedIn, ac.EvalPermission(ac.ActionTeamsRead, ac.ScopeTeamsID)), routing.Wrap(hs.GetTeamByID)) | 
					
						
							|  |  |  | 			teamsRoute.Get("/search", authorize(reqSignedIn, ac.EvalPermission(ac.ActionTeamsRead)), routing.Wrap(hs.SearchTeams)) | 
					
						
							| 
									
										
										
										
											2018-04-06 20:08:23 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 01:18:36 +08:00
										 |  |  | 		// org information available to all users.
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-23 18:12:37 +08:00
										 |  |  | 			orgRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(ActionOrgsRead)), routing.Wrap(hs.GetCurrentOrg)) | 
					
						
							| 
									
										
										
										
											2021-11-17 17:12:28 +08:00
										 |  |  | 			orgRoute.Get("/quotas", authorize(reqSignedIn, ac.EvalPermission(ActionOrgsQuotasRead)), routing.Wrap(hs.GetCurrentOrgQuotas)) | 
					
						
							| 
									
										
										
										
											2015-09-11 01:18:36 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-18 01:19:23 +08:00
										 |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagStorage) { | 
					
						
							|  |  |  | 			apiRoute.Group("/storage", func(orgRoute routing.RouteRegister) { | 
					
						
							|  |  |  | 				orgRoute.Get("/list/", routing.Wrap(hs.StorageService.List)) | 
					
						
							|  |  |  | 				orgRoute.Get("/list/*", routing.Wrap(hs.StorageService.List)) | 
					
						
							|  |  |  | 				orgRoute.Get("/read/*", routing.Wrap(hs.StorageService.Read)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-28 22:33:02 +08:00
										 |  |  | 				if hs.Features.IsEnabled(featuremgmt.FlagStorageLocalUpload) { | 
					
						
							|  |  |  | 					orgRoute.Delete("/delete/*", reqSignedIn, routing.Wrap(hs.StorageService.Delete)) | 
					
						
							|  |  |  | 					orgRoute.Post("/upload", reqSignedIn, routing.Wrap(hs.StorageService.Upload)) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2022-03-18 01:19:23 +08:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 01:18:36 +08:00
										 |  |  | 		// current org
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-10-07 17:54:43 +08:00
										 |  |  | 			userIDScope := ac.Scope("users", "id", ac.Parameter(":userId")) | 
					
						
							| 
									
										
										
										
											2022-01-26 03:30:08 +08:00
										 |  |  | 			orgRoute.Put("/", authorize(reqOrgAdmin, ac.EvalPermission(ActionOrgsWrite)), routing.Wrap(hs.UpdateCurrentOrg)) | 
					
						
							|  |  |  | 			orgRoute.Put("/address", authorize(reqOrgAdmin, ac.EvalPermission(ActionOrgsWrite)), routing.Wrap(hs.UpdateCurrentOrgAddress)) | 
					
						
							| 
									
										
										
										
											2022-01-13 21:40:32 +08:00
										 |  |  | 			orgRoute.Get("/users", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRead)), routing.Wrap(hs.GetOrgUsersForCurrentOrg)) | 
					
						
							|  |  |  | 			orgRoute.Get("/users/search", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRead)), routing.Wrap(hs.SearchOrgUsersWithPaging)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			orgRoute.Post("/users", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersAdd, ac.ScopeUsersAll)), quota("user"), routing.Wrap(hs.AddOrgUserToCurrentOrg)) | 
					
						
							|  |  |  | 			orgRoute.Patch("/users/:userId", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRoleUpdate, userIDScope)), routing.Wrap(hs.UpdateOrgUserForCurrentOrg)) | 
					
						
							| 
									
										
										
										
											2021-11-17 17:12:28 +08:00
										 |  |  | 			orgRoute.Delete("/users/:userId", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRemove, userIDScope)), routing.Wrap(hs.RemoveOrgUserForCurrentOrg)) | 
					
						
							| 
									
										
										
										
											2015-07-17 15:51:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// invites
 | 
					
						
							| 
									
										
										
										
											2022-02-01 00:24:52 +08:00
										 |  |  | 			orgRoute.Get("/invites", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionUsersCreate)), routing.Wrap(hs.GetPendingOrgInvites)) | 
					
						
							|  |  |  | 			orgRoute.Post("/invites", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionUsersCreate)), quota("user"), routing.Wrap(hs.AddOrgInvite)) | 
					
						
							|  |  |  | 			orgRoute.Patch("/invites/:code/revoke", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionUsersCreate)), routing.Wrap(hs.RevokeInvite)) | 
					
						
							| 
									
										
										
										
											2015-12-18 13:46:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 04:54:06 +08:00
										 |  |  | 			// prefs
 | 
					
						
							| 
									
										
										
										
											2021-11-17 17:12:28 +08:00
										 |  |  | 			orgRoute.Get("/preferences", authorize(reqOrgAdmin, ac.EvalPermission(ActionOrgsPreferencesRead)), routing.Wrap(hs.GetOrgPreferences)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			orgRoute.Put("/preferences", authorize(reqOrgAdmin, ac.EvalPermission(ActionOrgsPreferencesWrite)), routing.Wrap(hs.UpdateOrgPreferences)) | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | 			orgRoute.Patch("/preferences", authorize(reqOrgAdmin, ac.EvalPermission(ActionOrgsPreferencesWrite)), routing.Wrap(hs.PatchOrgPreferences)) | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-05-19 16:16:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 20:08:23 +08:00
										 |  |  | 		// current org without requirement of user to be org admin
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/org", func(orgRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-05-06 16:31:53 +08:00
										 |  |  | 			lookupEvaluator := func() ac.Evaluator { | 
					
						
							|  |  |  | 				if hs.Cfg.IsEnterprise { | 
					
						
							|  |  |  | 					return ac.EvalPermission(ac.ActionOrgUsersRead) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				// For oss we allow users with access to update permissions on either folders, teams or dashboards to perform the lookup
 | 
					
						
							|  |  |  | 				return ac.EvalAny( | 
					
						
							|  |  |  | 					ac.EvalPermission(ac.ActionOrgUsersRead), | 
					
						
							|  |  |  | 					ac.EvalPermission(ac.ActionTeamsPermissionsWrite), | 
					
						
							|  |  |  | 					ac.EvalPermission(dashboards.ActionDashboardsPermissionsWrite), | 
					
						
							|  |  |  | 					ac.EvalPermission(dashboards.ActionFoldersPermissionsWrite), | 
					
						
							|  |  |  | 				) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			orgRoute.Get("/users/lookup", authorize(reqOrgAdminFolderAdminOrTeamAdmin, lookupEvaluator()), routing.Wrap(hs.GetOrgUsersForCurrentOrgLookup)) | 
					
						
							| 
									
										
										
										
											2018-04-06 20:08:23 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 16:16:32 +08:00
										 |  |  | 		// create new org
 | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 		apiRoute.Post("/orgs", authorizeInOrg(reqSignedIn, ac.UseGlobalOrg, ac.EvalPermission(ActionOrgsCreate)), quota("org"), routing.Wrap(hs.CreateOrg)) | 
					
						
							| 
									
										
										
										
											2015-05-19 16:16:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 17:47:14 +08:00
										 |  |  | 		// search all orgs
 | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 		apiRoute.Get("/orgs", authorizeInOrg(reqGrafanaAdmin, ac.UseGlobalOrg, ac.EvalPermission(ActionOrgsRead)), routing.Wrap(hs.SearchOrgs)) | 
					
						
							| 
									
										
										
										
											2015-05-19 17:47:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-19 16:16:32 +08:00
										 |  |  | 		// orgs (admin routes)
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/orgs/:orgId", func(orgsRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-11-17 17:12:28 +08:00
										 |  |  | 			userIDScope := ac.Scope("users", "id", ac.Parameter(":userId")) | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 			orgsRoute.Get("/", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsRead)), routing.Wrap(hs.GetOrgByID)) | 
					
						
							|  |  |  | 			orgsRoute.Put("/", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsWrite)), routing.Wrap(hs.UpdateOrg)) | 
					
						
							|  |  |  | 			orgsRoute.Put("/address", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsWrite)), routing.Wrap(hs.UpdateOrgAddress)) | 
					
						
							|  |  |  | 			orgsRoute.Delete("/", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsDelete)), routing.Wrap(hs.DeleteOrgByID)) | 
					
						
							| 
									
										
										
										
											2022-05-13 15:26:34 +08:00
										 |  |  | 			orgsRoute.Get("/users", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ac.ActionOrgUsersRead)), routing.Wrap(hs.GetOrgUsers)) | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 			orgsRoute.Post("/users", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ac.ActionOrgUsersAdd, ac.ScopeUsersAll)), routing.Wrap(hs.AddOrgUser)) | 
					
						
							|  |  |  | 			orgsRoute.Patch("/users/:userId", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ac.ActionOrgUsersRoleUpdate, userIDScope)), routing.Wrap(hs.UpdateOrgUser)) | 
					
						
							|  |  |  | 			orgsRoute.Delete("/users/:userId", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ac.ActionOrgUsersRemove, userIDScope)), routing.Wrap(hs.RemoveOrgUser)) | 
					
						
							|  |  |  | 			orgsRoute.Get("/quotas", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsQuotasRead)), routing.Wrap(hs.GetOrgQuotas)) | 
					
						
							|  |  |  | 			orgsRoute.Put("/quotas/:target", authorizeInOrg(reqGrafanaAdmin, ac.UseOrgFromContextParams, ac.EvalPermission(ActionOrgsQuotasWrite)), routing.Wrap(hs.UpdateOrgQuota)) | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-01-27 03:26:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-13 05:50:56 +08:00
										 |  |  | 		// orgs (admin routes)
 | 
					
						
							| 
									
										
										
										
											2022-04-28 16:46:18 +08:00
										 |  |  | 		apiRoute.Get("/orgs/name/:name/", authorizeInOrg(reqGrafanaAdmin, ac.UseGlobalOrg, ac.EvalPermission(ActionOrgsRead)), routing.Wrap(hs.GetOrgByName)) | 
					
						
							| 
									
										
										
										
											2016-01-13 05:50:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-27 15:26:11 +08:00
										 |  |  | 		// auth api keys
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/auth/keys", func(keysRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-05 02:01:03 +08:00
										 |  |  | 			apikeyIDScope := ac.Scope("apikeys", "id", ac.Parameter(":id")) | 
					
						
							| 
									
										
										
										
											2022-04-29 21:30:24 +08:00
										 |  |  | 			keysRoute.Get("/", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionAPIKeyRead)), routing.Wrap(hs.GetAPIKeys)) | 
					
						
							| 
									
										
										
										
											2022-03-05 02:01:03 +08:00
										 |  |  | 			keysRoute.Post("/", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionAPIKeyCreate)), quota("api_key"), routing.Wrap(hs.AddAPIKey)) | 
					
						
							|  |  |  | 			keysRoute.Delete("/:id", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionAPIKeyDelete, apikeyIDScope)), routing.Wrap(hs.DeleteAPIKey)) | 
					
						
							| 
									
										
										
										
											2022-04-14 00:11:03 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-01-27 03:26:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-17 14:35:06 +08:00
										 |  |  | 		// Preferences
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/preferences", func(prefRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-03 16:20:20 +08:00
										 |  |  | 			prefRoute.Post("/set-home-dash", routing.Wrap(hs.SetHomeDashboard)) | 
					
						
							| 
									
										
										
										
											2016-03-17 14:35:06 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-03-11 22:30:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 		// Data sources
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/datasources", func(datasourceRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 			datasourceRoute.Get("/", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionRead)), routing.Wrap(hs.GetDataSources)) | 
					
						
							|  |  |  | 			datasourceRoute.Post("/", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionCreate)), quota("data_source"), routing.Wrap(hs.AddDataSource)) | 
					
						
							|  |  |  | 			datasourceRoute.Put("/:id", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionWrite, datasources.ScopeProvider.GetResourceScope(ac.Parameter(":id")))), routing.Wrap(hs.UpdateDataSource)) | 
					
						
							|  |  |  | 			datasourceRoute.Delete("/:id", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionDelete, datasources.ScopeProvider.GetResourceScope(ac.Parameter(":id")))), routing.Wrap(hs.DeleteDataSourceById)) | 
					
						
							|  |  |  | 			datasourceRoute.Delete("/uid/:uid", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionDelete, datasources.ScopeProvider.GetResourceScopeUID(ac.Parameter(":uid")))), routing.Wrap(hs.DeleteDataSourceByUID)) | 
					
						
							|  |  |  | 			datasourceRoute.Delete("/name/:name", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionDelete, datasources.ScopeProvider.GetResourceScopeName(ac.Parameter(":name")))), routing.Wrap(hs.DeleteDataSourceByName)) | 
					
						
							|  |  |  | 			datasourceRoute.Get("/:id", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionRead)), routing.Wrap(hs.GetDataSourceById)) | 
					
						
							|  |  |  | 			datasourceRoute.Get("/uid/:uid", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionRead)), routing.Wrap(hs.GetDataSourceByUID)) | 
					
						
							|  |  |  | 			datasourceRoute.Get("/name/:name", authorize(reqOrgAdmin, ac.EvalPermission(datasources.ActionRead)), routing.Wrap(hs.GetDataSourceByName)) | 
					
						
							| 
									
										
										
										
											2021-09-01 21:18:17 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Get("/datasources/id/:name", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionIDRead, datasources.ScopeProvider.GetResourceScopeName(ac.Parameter(":name")))), routing.Wrap(hs.GetDataSourceIdByName)) | 
					
						
							| 
									
										
										
										
											2016-03-08 04:25:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 		apiRoute.Get("/plugins", routing.Wrap(hs.GetPluginList)) | 
					
						
							| 
									
										
										
										
											2021-03-17 23:06:10 +08:00
										 |  |  | 		apiRoute.Get("/plugins/:pluginId/settings", routing.Wrap(hs.GetPluginSettingByID)) | 
					
						
							| 
									
										
										
										
											2021-03-08 14:02:49 +08:00
										 |  |  | 		apiRoute.Get("/plugins/:pluginId/markdown/:name", routing.Wrap(hs.GetPluginMarkdown)) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 		apiRoute.Get("/plugins/:pluginId/health", routing.Wrap(hs.CheckHealth)) | 
					
						
							| 
									
										
										
										
											2020-03-03 18:45:16 +08:00
										 |  |  | 		apiRoute.Any("/plugins/:pluginId/resources", hs.CallResource) | 
					
						
							|  |  |  | 		apiRoute.Any("/plugins/:pluginId/resources/*", hs.CallResource) | 
					
						
							| 
									
										
										
										
											2021-05-13 02:05:16 +08:00
										 |  |  | 		apiRoute.Get("/plugins/errors", routing.Wrap(hs.GetPluginErrorsList)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 17:49:05 +08:00
										 |  |  | 		apiRoute.Group("/plugins", func(pluginRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			pluginRoute.Post("/:pluginId/install", routing.Wrap(hs.InstallPlugin)) | 
					
						
							| 
									
										
										
										
											2021-08-04 17:49:05 +08:00
										 |  |  | 			pluginRoute.Post("/:pluginId/uninstall", routing.Wrap(hs.UninstallPlugin)) | 
					
						
							|  |  |  | 		}, reqGrafanaAdmin) | 
					
						
							| 
									
										
										
										
											2016-03-11 16:57:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/plugins", func(pluginRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-03-08 14:02:49 +08:00
										 |  |  | 			pluginRoute.Get("/:pluginId/dashboards/", routing.Wrap(hs.GetPluginDashboards)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			pluginRoute.Post("/:pluginId/settings", routing.Wrap(hs.UpdatePluginSetting)) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 			pluginRoute.Get("/:pluginId/metrics", routing.Wrap(hs.CollectPluginMetrics)) | 
					
						
							| 
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 |  |  | 		}, reqOrgAdmin) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 		apiRoute.Get("/frontend/settings/", hs.GetFrontendSettings) | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Any("/datasources/proxy/:id/*", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.ProxyDataSourceRequest) | 
					
						
							| 
									
										
										
										
											2022-04-14 18:28:13 +08:00
										 |  |  | 		apiRoute.Any("/datasources/proxy/uid/:uid/*", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.ProxyDataSourceRequestWithUID) | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Any("/datasources/proxy/:id", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.ProxyDataSourceRequest) | 
					
						
							| 
									
										
										
										
											2022-04-14 18:28:13 +08:00
										 |  |  | 		apiRoute.Any("/datasources/proxy/uid/:uid", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.ProxyDataSourceRequestWithUID) | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Any("/datasources/:id/resources", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.CallDatasourceResource) | 
					
						
							|  |  |  | 		apiRoute.Any("/datasources/:id/resources/*", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), hs.CallDatasourceResource) | 
					
						
							|  |  |  | 		apiRoute.Any("/datasources/:id/health", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.CheckDatasourceHealth)) | 
					
						
							| 
									
										
										
										
											2015-02-10 17:19:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-29 20:51:01 +08:00
										 |  |  | 		// Folders
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/folders", func(folderRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-30 21:14:26 +08:00
										 |  |  | 			idScope := dashboards.ScopeFoldersProvider.GetResourceScope(ac.Parameter(":id")) | 
					
						
							|  |  |  | 			uidScope := dashboards.ScopeFoldersProvider.GetResourceScopeUID(ac.Parameter(":uid")) | 
					
						
							| 
									
										
										
										
											2022-03-10 00:57:50 +08:00
										 |  |  | 			folderRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersRead)), routing.Wrap(hs.GetFolders)) | 
					
						
							| 
									
										
										
										
											2022-03-30 21:14:26 +08:00
										 |  |  | 			folderRoute.Get("/id/:id", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersRead, idScope)), routing.Wrap(hs.GetFolderByID)) | 
					
						
							| 
									
										
										
										
											2022-03-10 00:57:50 +08:00
										 |  |  | 			folderRoute.Post("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersCreate)), routing.Wrap(hs.CreateFolder)) | 
					
						
							| 
									
										
										
										
											2018-02-20 22:25:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 			folderRoute.Group("/:uid", func(folderUidRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-30 21:14:26 +08:00
										 |  |  | 				folderUidRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersRead, uidScope)), routing.Wrap(hs.GetFolderByUID)) | 
					
						
							|  |  |  | 				folderUidRoute.Put("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersWrite, uidScope)), routing.Wrap(hs.UpdateFolder)) | 
					
						
							|  |  |  | 				folderUidRoute.Delete("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersDelete, uidScope)), routing.Wrap(hs.DeleteFolder)) | 
					
						
							| 
									
										
										
										
											2018-02-20 22:25:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 				folderUidRoute.Group("/permissions", func(folderPermissionRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-30 21:14:26 +08:00
										 |  |  | 					folderPermissionRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersPermissionsRead, uidScope)), routing.Wrap(hs.GetFolderPermissionList)) | 
					
						
							|  |  |  | 					folderPermissionRoute.Post("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionFoldersPermissionsWrite, uidScope)), routing.Wrap(hs.UpdateFolderPermissions)) | 
					
						
							| 
									
										
										
										
											2018-02-20 22:25:16 +08:00
										 |  |  | 				}) | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2018-01-29 20:51:01 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 		// Dashboard
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/dashboards", func(dashboardRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 			dashboardRoute.Get("/uid/:uid", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsRead)), routing.Wrap(hs.GetDashboard)) | 
					
						
							|  |  |  | 			dashboardRoute.Delete("/uid/:uid", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsDelete)), routing.Wrap(hs.DeleteDashboardByUID)) | 
					
						
							| 
									
										
										
										
											2022-04-21 22:24:03 +08:00
										 |  |  | 			dashboardRoute.Group("/uid/:uid", func(dashUidRoute routing.RouteRegister) { | 
					
						
							|  |  |  | 				dashUidRoute.Group("/permissions", func(dashboardPermissionRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 					dashboardPermissionRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsPermissionsRead)), routing.Wrap(hs.GetDashboardPermissionList)) | 
					
						
							|  |  |  | 					dashboardPermissionRoute.Post("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsPermissionsWrite)), routing.Wrap(hs.UpdateDashboardPermissions)) | 
					
						
							| 
									
										
										
										
											2022-04-21 22:24:03 +08:00
										 |  |  | 				}) | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2018-01-30 04:23:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-24 01:43:53 +08:00
										 |  |  | 			if hs.ThumbService != nil { | 
					
						
							| 
									
										
										
										
											2022-02-09 17:23:32 +08:00
										 |  |  | 				dashboardRoute.Get("/uid/:uid/img/:kind/:theme", hs.ThumbService.GetImage) | 
					
						
							| 
									
										
										
										
											2022-02-17 16:34:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				if hs.Features.IsEnabled(featuremgmt.FlagDashboardPreviewsAdmin) { | 
					
						
							|  |  |  | 					dashboardRoute.Post("/uid/:uid/img/:kind/:theme", reqGrafanaAdmin, hs.ThumbService.SetImage) | 
					
						
							|  |  |  | 					dashboardRoute.Put("/uid/:uid/img/:kind/:theme", reqGrafanaAdmin, hs.ThumbService.UpdateThumbnailState) | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2021-12-24 01:43:53 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 			dashboardRoute.Post("/calculate-diff", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.CalculateDashboardDiff)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			dashboardRoute.Post("/trim", routing.Wrap(hs.TrimDashboard)) | 
					
						
							| 
									
										
										
										
											2017-06-07 17:50:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 			dashboardRoute.Post("/db", authorize(reqSignedIn, ac.EvalAny(ac.EvalPermission(dashboards.ActionDashboardsCreate), ac.EvalPermission(dashboards.ActionDashboardsWrite))), routing.Wrap(hs.PostDashboard)) | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 			dashboardRoute.Get("/home", routing.Wrap(hs.GetHomeDashboard)) | 
					
						
							| 
									
										
										
										
											2022-02-07 19:43:43 +08:00
										 |  |  | 			dashboardRoute.Get("/tags", hs.GetDashboardTags) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:38:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-21 22:24:03 +08:00
										 |  |  | 			// Deprecated: use /uid/:uid API instead.
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 			dashboardRoute.Group("/id/:dashboardId", func(dashIdRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 				dashIdRoute.Get("/versions", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.GetDashboardVersions)) | 
					
						
							|  |  |  | 				dashIdRoute.Get("/versions/:id", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.GetDashboardVersion)) | 
					
						
							|  |  |  | 				dashIdRoute.Post("/restore", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsWrite)), routing.Wrap(hs.RestoreDashboardVersion)) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:38:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 				dashIdRoute.Group("/permissions", func(dashboardPermissionRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 					dashboardPermissionRoute.Get("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsPermissionsRead)), routing.Wrap(hs.GetDashboardPermissionList)) | 
					
						
							|  |  |  | 					dashboardPermissionRoute.Post("/", authorize(reqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsPermissionsWrite)), routing.Wrap(hs.UpdateDashboardPermissions)) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:38:49 +08:00
										 |  |  | 				}) | 
					
						
							|  |  |  | 			}) | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-01-27 03:26:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 21:05:24 +08:00
										 |  |  | 		// Dashboard snapshots
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/dashboard/snapshots", func(dashboardRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-09 00:57:59 +08:00
										 |  |  | 			dashboardRoute.Get("/", routing.Wrap(hs.SearchDashboardSnapshots)) | 
					
						
							| 
									
										
										
										
											2016-01-19 21:05:24 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-01-19 17:37:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-22 18:07:15 +08:00
										 |  |  | 		// Playlist
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/playlists", func(playlistRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-01-27 17:33:02 +08:00
										 |  |  | 			playlistRoute.Get("/", routing.Wrap(hs.SearchPlaylists)) | 
					
						
							|  |  |  | 			playlistRoute.Get("/:id", hs.ValidateOrgPlaylist, routing.Wrap(hs.GetPlaylist)) | 
					
						
							|  |  |  | 			playlistRoute.Get("/:id/items", hs.ValidateOrgPlaylist, routing.Wrap(hs.GetPlaylistItems)) | 
					
						
							|  |  |  | 			playlistRoute.Get("/:id/dashboards", hs.ValidateOrgPlaylist, routing.Wrap(hs.GetPlaylistDashboards)) | 
					
						
							|  |  |  | 			playlistRoute.Delete("/:id", reqEditorRole, hs.ValidateOrgPlaylist, routing.Wrap(hs.DeletePlaylist)) | 
					
						
							|  |  |  | 			playlistRoute.Put("/:id", reqEditorRole, hs.ValidateOrgPlaylist, routing.Wrap(hs.UpdatePlaylist)) | 
					
						
							|  |  |  | 			playlistRoute.Post("/", reqEditorRole, routing.Wrap(hs.CreatePlaylist)) | 
					
						
							| 
									
										
										
										
											2015-12-22 18:07:15 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 		// Search
 | 
					
						
							| 
									
										
										
										
											2021-01-15 21:43:20 +08:00
										 |  |  | 		apiRoute.Get("/search/sorting", routing.Wrap(hs.ListSortOptions)) | 
					
						
							| 
									
										
										
										
											2022-02-04 01:46:38 +08:00
										 |  |  | 		apiRoute.Get("/search/", routing.Wrap(hs.Search)) | 
					
						
							| 
									
										
										
										
											2015-01-27 03:26:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 21:25:12 +08:00
										 |  |  | 		// metrics
 | 
					
						
							| 
									
										
										
										
											2022-03-30 23:46:06 +08:00
										 |  |  | 		// Deprecated: use /ds/query API instead.
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Post("/tsdb/query", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.QueryMetrics)) | 
					
						
							| 
									
										
										
										
											2017-09-13 20:53:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 07:22:00 +08:00
										 |  |  | 		// DataSource w/ expressions
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Post("/ds/query", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.QueryMetricsV2)) | 
					
						
							| 
									
										
										
										
											2019-11-01 07:22:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-08 02:33:01 +08:00
										 |  |  | 		// Validated query
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 		apiRoute.Post("/dashboards/org/:orgId/uid/:dashboardUid/panels/:panelId/query", authorize(reqSignedIn, ac.EvalPermission(datasources.ActionQuery)), routing.Wrap(hs.QueryMetricsFromDashboard)) | 
					
						
							| 
									
										
										
										
											2022-03-08 02:33:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/alerts", func(alertsRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			alertsRoute.Post("/test", routing.Wrap(hs.AlertTest)) | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			alertsRoute.Post("/:alertId/pause", reqEditorRole, routing.Wrap(hs.PauseAlert)) | 
					
						
							|  |  |  | 			alertsRoute.Get("/:alertId", hs.ValidateOrgAlert, routing.Wrap(hs.GetAlert)) | 
					
						
							|  |  |  | 			alertsRoute.Get("/", routing.Wrap(hs.GetAlerts)) | 
					
						
							|  |  |  | 			alertsRoute.Get("/states-for-dashboard", routing.Wrap(hs.GetAlertStatesForDashboard)) | 
					
						
							| 
									
										
										
										
											2016-04-26 23:36:50 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 00:24:33 +08:00
										 |  |  | 		var notifiersAuthHandler web.Handler | 
					
						
							|  |  |  | 		if hs.Cfg.UnifiedAlerting.IsEnabled() { | 
					
						
							|  |  |  | 			notifiersAuthHandler = reqSignedIn | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			notifiersAuthHandler = reqEditorRole | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		apiRoute.Get("/alert-notifiers", notifiersAuthHandler, routing.Wrap( | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			hs.GetAlertNotifiers(hs.Cfg.UnifiedAlerting.IsEnabled())), | 
					
						
							| 
									
										
										
										
											2021-05-04 19:58:39 +08:00
										 |  |  | 		) | 
					
						
							| 
									
										
										
										
											2016-07-14 19:32:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/alert-notifications", func(alertNotifications routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			alertNotifications.Get("/", routing.Wrap(hs.GetAlertNotifications)) | 
					
						
							|  |  |  | 			alertNotifications.Post("/test", routing.Wrap(hs.NotificationTest)) | 
					
						
							|  |  |  | 			alertNotifications.Post("/", routing.Wrap(hs.CreateAlertNotification)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			alertNotifications.Put("/:notificationId", routing.Wrap(hs.UpdateAlertNotification)) | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			alertNotifications.Get("/:notificationId", routing.Wrap(hs.GetAlertNotificationByID)) | 
					
						
							|  |  |  | 			alertNotifications.Delete("/:notificationId", routing.Wrap(hs.DeleteAlertNotification)) | 
					
						
							|  |  |  | 			alertNotifications.Get("/uid/:uid", routing.Wrap(hs.GetAlertNotificationByUID)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			alertNotifications.Put("/uid/:uid", routing.Wrap(hs.UpdateAlertNotificationByUID)) | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			alertNotifications.Delete("/uid/:uid", routing.Wrap(hs.DeleteAlertNotificationByUID)) | 
					
						
							| 
									
										
										
										
											2016-10-19 14:01:14 +08:00
										 |  |  | 		}, reqEditorRole) | 
					
						
							| 
									
										
										
										
											2016-07-14 19:32:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 02:03:48 +08:00
										 |  |  | 		// alert notifications without requirement of user to be org editor
 | 
					
						
							|  |  |  | 		apiRoute.Group("/alert-notifications", func(orgRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 			orgRoute.Get("/lookup", routing.Wrap(hs.GetAlertNotificationLookup)) | 
					
						
							| 
									
										
										
										
											2019-08-13 02:03:48 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-11 20:18:38 +08:00
										 |  |  | 		apiRoute.Get("/annotations", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsRead)), routing.Wrap(hs.GetAnnotations)) | 
					
						
							| 
									
										
										
										
											2022-03-24 05:39:00 +08:00
										 |  |  | 		apiRoute.Post("/annotations/mass-delete", authorize(reqOrgAdmin, ac.EvalPermission(ac.ActionAnnotationsDelete)), routing.Wrap(hs.MassDeleteAnnotations)) | 
					
						
							| 
									
										
										
										
											2017-04-12 21:46:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 		apiRoute.Group("/annotations", func(annotationsRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-22 01:28:39 +08:00
										 |  |  | 			annotationsRoute.Post("/", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsCreate)), routing.Wrap(hs.PostAnnotation)) | 
					
						
							| 
									
										
										
										
											2022-05-16 23:16:36 +08:00
										 |  |  | 			annotationsRoute.Get("/:annotationId", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsRead, ac.ScopeAnnotationsID)), routing.Wrap(hs.GetAnnotationByID)) | 
					
						
							| 
									
										
										
										
											2022-03-22 01:28:39 +08:00
										 |  |  | 			annotationsRoute.Delete("/:annotationId", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsDelete, ac.ScopeAnnotationsID)), routing.Wrap(hs.DeleteAnnotationByID)) | 
					
						
							| 
									
										
										
										
											2022-03-19 00:33:21 +08:00
										 |  |  | 			annotationsRoute.Put("/:annotationId", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsWrite, ac.ScopeAnnotationsID)), routing.Wrap(hs.UpdateAnnotation)) | 
					
						
							|  |  |  | 			annotationsRoute.Patch("/:annotationId", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsWrite, ac.ScopeAnnotationsID)), routing.Wrap(hs.PatchAnnotation)) | 
					
						
							| 
									
										
										
										
											2022-03-22 01:28:39 +08:00
										 |  |  | 			annotationsRoute.Post("/graphite", authorize(reqEditorRole, ac.EvalPermission(ac.ActionAnnotationsCreate, ac.ScopeAnnotationsTypeOrganization)), routing.Wrap(hs.PostGraphiteAnnotation)) | 
					
						
							| 
									
										
										
										
											2022-04-04 20:53:58 +08:00
										 |  |  | 			annotationsRoute.Get("/tags", authorize(reqSignedIn, ac.EvalPermission(ac.ActionAnnotationsRead)), routing.Wrap(hs.GetAnnotationTags)) | 
					
						
							| 
									
										
										
										
											2017-12-21 07:52:21 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-09-08 17:25:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		apiRoute.Post("/frontend-metrics", routing.Wrap(hs.PostFrontendMetrics)) | 
					
						
							| 
									
										
										
										
											2021-04-02 02:04:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 23:44:55 +08:00
										 |  |  | 		apiRoute.Group("/live", func(liveRoute routing.RouteRegister) { | 
					
						
							|  |  |  | 			// the channel path is in the name
 | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 			liveRoute.Post("/publish", routing.Wrap(hs.Live.HandleHTTPPublish)) | 
					
						
							| 
									
										
										
										
											2021-04-06 00:04:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-10 00:19:29 +08:00
										 |  |  | 			// POST influx line protocol.
 | 
					
						
							| 
									
										
										
										
											2021-05-04 23:44:55 +08:00
										 |  |  | 			liveRoute.Post("/push/:streamId", hs.LivePushGateway.Handle) | 
					
						
							| 
									
										
										
										
											2021-04-06 00:04:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 23:44:55 +08:00
										 |  |  | 			// List available streams and fields
 | 
					
						
							|  |  |  | 			liveRoute.Get("/list", routing.Wrap(hs.Live.HandleListHTTP)) | 
					
						
							| 
									
										
										
										
											2021-04-24 03:55:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 23:44:55 +08:00
										 |  |  | 			// Some channels may have info
 | 
					
						
							|  |  |  | 			liveRoute.Get("/info/*", routing.Wrap(hs.Live.HandleInfoHTTP)) | 
					
						
							| 
									
										
										
										
											2021-09-10 00:19:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 01:44:20 +08:00
										 |  |  | 			if hs.Features.IsEnabled(featuremgmt.FlagLivePipeline) { | 
					
						
							| 
									
										
										
										
											2021-09-10 00:19:29 +08:00
										 |  |  | 				// POST Live data to be processed according to channel rules.
 | 
					
						
							| 
									
										
										
										
											2021-11-15 17:43:18 +08:00
										 |  |  | 				liveRoute.Post("/pipeline/push/*", hs.LivePushGateway.HandlePipelinePush) | 
					
						
							| 
									
										
										
										
											2021-10-01 01:28:06 +08:00
										 |  |  | 				liveRoute.Post("/pipeline-convert-test", routing.Wrap(hs.Live.HandlePipelineConvertTestHTTP), reqOrgAdmin) | 
					
						
							| 
									
										
										
										
											2021-11-05 17:13:40 +08:00
										 |  |  | 				liveRoute.Get("/pipeline-entities", routing.Wrap(hs.Live.HandlePipelineEntitiesListHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Get("/channel-rules", routing.Wrap(hs.Live.HandleChannelRulesListHTTP), reqOrgAdmin) | 
					
						
							| 
									
										
										
										
											2021-10-01 00:29:32 +08:00
										 |  |  | 				liveRoute.Post("/channel-rules", routing.Wrap(hs.Live.HandleChannelRulesPostHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Put("/channel-rules", routing.Wrap(hs.Live.HandleChannelRulesPutHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Delete("/channel-rules", routing.Wrap(hs.Live.HandleChannelRulesDeleteHTTP), reqOrgAdmin) | 
					
						
							| 
									
										
										
										
											2021-11-10 00:12:10 +08:00
										 |  |  | 				liveRoute.Get("/write-configs", routing.Wrap(hs.Live.HandleWriteConfigsListHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Post("/write-configs", routing.Wrap(hs.Live.HandleWriteConfigsPostHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Put("/write-configs", routing.Wrap(hs.Live.HandleWriteConfigsPutHTTP), reqOrgAdmin) | 
					
						
							|  |  |  | 				liveRoute.Delete("/write-configs", routing.Wrap(hs.Live.HandleWriteConfigsDeleteHTTP), reqOrgAdmin) | 
					
						
							| 
									
										
										
										
											2021-09-10 00:19:29 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-05-04 23:44:55 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-03-30 18:23:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-14 18:48:48 +08:00
										 |  |  | 		// short urls
 | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		apiRoute.Post("/short-urls", routing.Wrap(hs.createShortURL)) | 
					
						
							| 
									
										
										
										
											2022-02-22 15:47:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		apiRoute.Group("/comments", func(commentRoute routing.RouteRegister) { | 
					
						
							|  |  |  | 			commentRoute.Post("/get", routing.Wrap(hs.commentsGet)) | 
					
						
							|  |  |  | 			commentRoute.Post("/create", routing.Wrap(hs.commentsCreate)) | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2015-01-15 19:16:54 +08:00
										 |  |  | 	}, reqSignedIn) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// admin api
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:36:47 +08:00
										 |  |  | 	r.Group("/api/admin", func(adminRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 		adminRoute.Get("/settings", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead)), routing.Wrap(hs.AdminGetSettings)) | 
					
						
							| 
									
										
										
										
											2022-01-27 01:44:20 +08:00
										 |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagShowFeatureFlagsInUI) { | 
					
						
							|  |  |  | 			adminRoute.Get("/settings/features", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead)), hs.Features.HandleGetSettings) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-02-05 00:53:58 +08:00
										 |  |  | 		adminRoute.Get("/stats", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionServerStatsRead)), routing.Wrap(hs.AdminGetStats)) | 
					
						
							| 
									
										
										
										
											2022-02-04 20:41:15 +08:00
										 |  |  | 		adminRoute.Post("/pause-all-alerts", reqGrafanaAdmin, routing.Wrap(hs.PauseAllAlerts)) | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-17 16:34:07 +08:00
										 |  |  | 		if hs.ThumbService != nil && hs.Features.IsEnabled(featuremgmt.FlagDashboardPreviewsAdmin) { | 
					
						
							| 
									
										
										
										
											2022-01-11 00:21:35 +08:00
										 |  |  | 			adminRoute.Post("/crawler/start", reqGrafanaAdmin, routing.Wrap(hs.ThumbService.StartCrawler)) | 
					
						
							|  |  |  | 			adminRoute.Post("/crawler/stop", reqGrafanaAdmin, routing.Wrap(hs.ThumbService.StopCrawler)) | 
					
						
							|  |  |  | 			adminRoute.Get("/crawler/status", reqGrafanaAdmin, routing.Wrap(hs.ThumbService.CrawlerStatus)) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-26 07:59:18 +08:00
										 |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagExport) { | 
					
						
							|  |  |  | 			adminRoute.Get("/export", reqGrafanaAdmin, routing.Wrap(hs.ExportService.HandleGetStatus)) | 
					
						
							|  |  |  | 			adminRoute.Post("/export", reqGrafanaAdmin, routing.Wrap(hs.ExportService.HandleRequestExport)) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 		adminRoute.Post("/provisioning/dashboards/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersDashboards)), routing.Wrap(hs.AdminProvisioningReloadDashboards)) | 
					
						
							|  |  |  | 		adminRoute.Post("/provisioning/plugins/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersPlugins)), routing.Wrap(hs.AdminProvisioningReloadPlugins)) | 
					
						
							|  |  |  | 		adminRoute.Post("/provisioning/datasources/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersDatasources)), routing.Wrap(hs.AdminProvisioningReloadDatasources)) | 
					
						
							|  |  |  | 		adminRoute.Post("/provisioning/notifications/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersNotifications)), routing.Wrap(hs.AdminProvisioningReloadNotifications)) | 
					
						
							| 
									
										
										
										
											2021-08-04 20:44:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 		adminRoute.Post("/ldap/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPConfigReload)), routing.Wrap(hs.ReloadLDAPCfg)) | 
					
						
							|  |  |  | 		adminRoute.Post("/ldap/sync/:id", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPUsersSync)), routing.Wrap(hs.PostSyncUserWithLDAP)) | 
					
						
							|  |  |  | 		adminRoute.Get("/ldap/:username", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPUsersRead)), routing.Wrap(hs.GetUserFromLDAP)) | 
					
						
							|  |  |  | 		adminRoute.Get("/ldap/status", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPStatusRead)), routing.Wrap(hs.GetLDAPStatus)) | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 22:31:27 +08:00
										 |  |  | 	// Administering users
 | 
					
						
							|  |  |  | 	r.Group("/api/admin/users", func(adminUserRoute routing.RouteRegister) { | 
					
						
							| 
									
										
										
										
											2022-03-22 19:48:46 +08:00
										 |  |  | 		userIDScope := ac.Scope("global.users", "id", ac.Parameter(":id")) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		adminUserRoute.Post("/", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersCreate)), routing.Wrap(hs.AdminCreateUser)) | 
					
						
							| 
									
										
										
										
											2022-02-05 02:45:42 +08:00
										 |  |  | 		adminUserRoute.Put("/:id/password", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersPasswordUpdate, userIDScope)), routing.Wrap(hs.AdminUpdateUserPassword)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		adminUserRoute.Put("/:id/permissions", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersPermissionsUpdate, userIDScope)), routing.Wrap(hs.AdminUpdateUserPermissions)) | 
					
						
							| 
									
										
										
										
											2022-02-05 02:45:42 +08:00
										 |  |  | 		adminUserRoute.Delete("/:id", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersDelete, userIDScope)), routing.Wrap(hs.AdminDeleteUser)) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 		adminUserRoute.Post("/:id/disable", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersDisable, userIDScope)), routing.Wrap(hs.AdminDisableUser)) | 
					
						
							| 
									
										
										
										
											2022-02-05 02:45:42 +08:00
										 |  |  | 		adminUserRoute.Post("/:id/enable", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersEnable, userIDScope)), routing.Wrap(hs.AdminEnableUser)) | 
					
						
							| 
									
										
										
										
											2022-02-03 16:20:20 +08:00
										 |  |  | 		adminUserRoute.Get("/:id/quotas", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersQuotasList, userIDScope)), routing.Wrap(hs.GetUserQuotas)) | 
					
						
							|  |  |  | 		adminUserRoute.Put("/:id/quotas/:target", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersQuotasUpdate, userIDScope)), routing.Wrap(hs.UpdateUserQuota)) | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		adminUserRoute.Post("/:id/logout", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersLogout, userIDScope)), routing.Wrap(hs.AdminLogoutUser)) | 
					
						
							|  |  |  | 		adminUserRoute.Get("/:id/auth-tokens", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersAuthTokenList, userIDScope)), routing.Wrap(hs.AdminGetUserAuthTokens)) | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		adminUserRoute.Post("/:id/revoke-auth-token", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersAuthTokenUpdate, userIDScope)), routing.Wrap(hs.AdminRevokeUserAuthToken)) | 
					
						
							| 
									
										
										
										
											2021-04-14 22:31:27 +08:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | 	// rendering
 | 
					
						
							| 
									
										
										
										
											2018-05-24 21:26:27 +08:00
										 |  |  | 	r.Get("/render/*", reqSignedIn, hs.RenderToPng) | 
					
						
							| 
									
										
										
										
											2015-01-06 16:11:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-09 04:42:33 +08:00
										 |  |  | 	// grafana.net proxy
 | 
					
						
							| 
									
										
										
										
											2021-11-12 18:07:12 +08:00
										 |  |  | 	r.Any("/api/gnet/*", reqSignedIn, hs.ProxyGnetRequest) | 
					
						
							| 
									
										
										
										
											2016-04-09 04:42:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-21 06:51:22 +08:00
										 |  |  | 	// Gravatar service.
 | 
					
						
							| 
									
										
										
										
											2022-04-06 10:56:17 +08:00
										 |  |  | 	r.Get("/avatar/:hash", hs.AvatarCacheServer.Handler) | 
					
						
							| 
									
										
										
										
											2016-02-21 06:51:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-02 21:15:46 +08:00
										 |  |  | 	// Snapshots
 | 
					
						
							| 
									
										
										
										
											2022-02-09 00:57:59 +08:00
										 |  |  | 	r.Post("/api/snapshots/", reqSnapshotPublicModeOrSignedIn, hs.CreateDashboardSnapshot) | 
					
						
							| 
									
										
										
										
											2019-09-02 21:15:46 +08:00
										 |  |  | 	r.Get("/api/snapshot/shared-options/", reqSignedIn, GetSharingOptions) | 
					
						
							| 
									
										
										
										
											2022-02-09 00:57:59 +08:00
										 |  |  | 	r.Get("/api/snapshots/:key", routing.Wrap(hs.GetDashboardSnapshot)) | 
					
						
							|  |  |  | 	r.Get("/api/snapshots-delete/:deleteKey", reqSnapshotPublicModeOrSignedIn, routing.Wrap(hs.DeleteDashboardSnapshotByDeleteKey)) | 
					
						
							|  |  |  | 	r.Delete("/api/snapshots/:key", reqEditorRole, routing.Wrap(hs.DeleteDashboardSnapshot)) | 
					
						
							| 
									
										
										
										
											2020-11-12 19:29:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Frontend logs
 | 
					
						
							| 
									
										
										
										
											2021-11-01 17:53:33 +08:00
										 |  |  | 	sourceMapStore := frontendlogging.NewSourceMapStore(hs.Cfg, hs.pluginStaticRouteResolver, frontendlogging.ReadSourceMapFromFS) | 
					
						
							| 
									
										
										
										
											2021-03-18 20:53:01 +08:00
										 |  |  | 	r.Post("/log", middleware.RateLimit(hs.Cfg.Sentry.EndpointRPS, hs.Cfg.Sentry.EndpointBurst, time.Now), | 
					
						
							| 
									
										
										
										
											2021-11-29 17:18:01 +08:00
										 |  |  | 		routing.Wrap(NewFrontendLogMessageHandler(sourceMapStore))) | 
					
						
							| 
									
										
										
										
											2014-12-16 04:25:02 +08:00
										 |  |  | } |