@ -36,7 +36,6 @@ import (
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/apikey"
"github.com/grafana/grafana/pkg/services/auth"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/correlations"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/datasources"
@ -61,11 +60,8 @@ func (hs *HTTPServer) registerRoutes() {
reqGrafanaAdmin := middleware . ReqGrafanaAdmin
reqEditorRole := middleware . ReqEditorRole
reqOrgAdmin := middleware . ReqOrgAdmin
reqOrgAdminDashOrFolderAdminOrTeamAdmin := middleware . OrgAdminDashOrFolderAdminOrTeamAdmin ( hs . SQLStore , hs . DashboardService , hs . teamService )
reqCanAccessTeams := middleware . AdminOrEditorAndFeatureEnabled ( hs . Cfg . EditorsCanAdmin )
reqSnapshotPublicModeOrSignedIn := middleware . SnapshotPublicModeOrSignedIn ( hs . Cfg )
redirectFromLegacyPanelEditURL := middleware . RedirectFromLegacyPanelEditURL ( hs . Cfg )
ensureEditorOrViewerCanEdit := middleware . EnsureEditorOrViewerCanEdit ( hs . Cfg )
authorize := ac . Middleware ( hs . AccessControl )
authorizeInOrg := ac . AuthorizeInOrgMiddleware ( hs . AccessControl , hs . accesscontrolService , hs . userService )
quota := middleware . Quota ( hs . QuotaService )
@ -85,32 +81,32 @@ func (hs *HTTPServer) registerRoutes() {
r . Get ( "/profile/password" , reqSignedInNoAnonymous , hs . Index )
r . Get ( "/.well-known/change-password" , redirectToChangePassword )
r . Get ( "/profile/switch-org/:id" , reqSignedInNoAnonymous , hs . ChangeActiveOrgAndRedirectToHome )
r . Get ( "/org/" , authorize ( reqOrgAdmin , ac . OrgPreferencesAccessEvaluator ) , hs . Index )
r . Get ( "/org/new" , authorizeInOrg ( reqGrafanaAdmin , ac . UseGlobalOrg , ac . OrgsCreateAccessEvaluator ) , hs . Index )
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 )
r . Get ( "/datasources/correlations" , authorize ( reqOrgAdmin , correlations . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/org/users" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , hs . Index )
r . Get ( "/org/" , authorize ( ac . OrgPreferencesAccessEvaluator ) , hs . Index )
r . Get ( "/org/new" , authorizeInOrg ( ac . UseGlobalOrg , ac . OrgsCreateAccessEvaluator ) , hs . Index )
r . Get ( "/datasources/" , authorize ( datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/datasources/new" , authorize ( datasources . NewPageAccess ) , hs . Index )
r . Get ( "/datasources/edit/*" , authorize ( datasources . EditPageAccess ) , hs . Index )
r . Get ( "/datasources/correlations" , authorize ( correlations . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/org/users" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , hs . Index )
r . Get ( "/org/users/new" , reqOrgAdmin , hs . Index )
r . Get ( "/org/users/invite" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , hs . Index )
r . Get ( "/org/teams" , authorize ( reqCanAccessTeams , ac . EvalPermission ( ac . ActionTeamsRead ) ) , hs . Index )
r . Get ( "/org/teams/edit/*" , authorize ( reqCanAccessTeams , ac . TeamsEditAccessEvaluator ) , hs . Index )
r . Get ( "/org/teams/new" , authorize ( reqCanAccessTeams , ac . EvalPermission ( ac . ActionTeamsCreate ) ) , hs . Index )
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 )
r . Get ( "/org/users/invite" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , hs . Index )
r . Get ( "/org/teams" , authorize ( ac . EvalPermission ( ac . ActionTeamsRead ) ) , hs . Index )
r . Get ( "/org/teams/edit/*" , authorize ( ac . TeamsEditAccessEvaluator ) , hs . Index )
r . Get ( "/org/teams/new" , authorize ( ac . EvalPermission ( ac . ActionTeamsCreate ) ) , hs . Index )
r . Get ( "/org/serviceaccounts" , authorize ( ac . EvalPermission ( serviceaccounts . ActionRead ) ) , hs . Index )
r . Get ( "/org/serviceaccounts/:serviceAccountId" , authorize ( ac . EvalPermission ( serviceaccounts . ActionRead ) ) , hs . Index )
r . Get ( "/org/apikeys/" , authorize ( ac . EvalPermission ( ac . ActionAPIKeyRead ) ) , hs . Index )
r . Get ( "/dashboard/import/" , reqSignedIn , hs . Index )
r . Get ( "/configuration" , reqGrafanaAdmin , hs . Index )
r . Get ( "/admin" , reqOrgAdmin , hs . Index )
r . Get ( "/admin/settings" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionSettingsRead , ac . ScopeSettingsAll ) ) , hs . Index )
r . Get ( "/admin/users" , authorize ( reqSignedIn , ac . EvalAny ( ac . EvalPermission ( ac . ActionOrgUsersRead ) , 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 )
r . Get ( "/admin/orgs" , authorizeInOrg ( reqGrafanaAdmin , ac . UseGlobalOrg , ac . OrgsAccessEvaluator ) , hs . Index )
r . Get ( "/admin/orgs/edit/:id" , authorizeInOrg ( reqGrafanaAdmin , ac . UseGlobalOrg , ac . OrgsAccessEvaluator ) , hs . Index )
r . Get ( "/admin/stats" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionServerStatsRead ) ) , hs . Index )
r . Get ( "/admin/ldap" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionLDAPStatusRead ) ) , hs . Index )
r . Get ( "/admin/settings" , authorize ( ac . EvalPermission ( ac . ActionSettingsRead , ac . ScopeSettingsAll ) ) , hs . Index )
r . Get ( "/admin/users" , authorize ( ac . EvalAny ( ac . EvalPermission ( ac . ActionOrgUsersRead ) , ac . EvalPermission ( ac . ActionUsersRead , ac . ScopeGlobalUsersAll ) ) ) , hs . Index )
r . Get ( "/admin/users/create" , authorize ( ac . EvalPermission ( ac . ActionUsersCreate ) ) , hs . Index )
r . Get ( "/admin/users/edit/:id" , authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) , hs . Index )
r . Get ( "/admin/orgs" , authorizeInOrg ( ac . UseGlobalOrg , ac . OrgsAccessEvaluator ) , hs . Index )
r . Get ( "/admin/orgs/edit/:id" , authorizeInOrg ( ac . UseGlobalOrg , ac . OrgsAccessEvaluator ) , hs . Index )
r . Get ( "/admin/stats" , authorize ( ac . EvalPermission ( ac . ActionServerStatsRead ) ) , hs . Index )
r . Get ( "/admin/ldap" , authorize ( ac . EvalPermission ( ac . ActionLDAPStatusRead ) ) , hs . Index )
if hs . Features . IsEnabled ( featuremgmt . FlagStorage ) {
r . Get ( "/admin/storage" , reqSignedIn , hs . Index )
r . Get ( "/admin/storage/*" , reqSignedIn , hs . Index )
@ -126,18 +122,18 @@ func (hs *HTTPServer) registerRoutes() {
r . Get ( "/plugins/:id/edit" , middleware . CanAdminPlugins ( hs . Cfg ) , hs . Index ) // deprecated
r . Get ( "/plugins/:id/page/:page" , middleware . CanAdminPlugins ( hs . Cfg ) , hs . Index )
r . Get ( "/connections/datasources" , authorize ( reqOrgAdmin , datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/datasources/new" , authorize ( reqOrgAdmin , datasources . NewPageAccess ) , hs . Index )
r . Get ( "/connections/datasources/edit/*" , authorize ( reqOrgAdmin , datasources . EditPageAccess ) , hs . Index )
r . Get ( "/connections" , authorize ( reqOrgAdmin , datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/add-new-connection" , authorize ( reqOrgAdmin , datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/datasources" , authorize ( datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/datasources/new" , authorize ( datasources . NewPageAccess ) , hs . Index )
r . Get ( "/connections/datasources/edit/*" , authorize ( datasources . EditPageAccess ) , hs . Index )
r . Get ( "/connections" , authorize ( datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/add-new-connection" , authorize ( datasources . ConfigurationPageAccess ) , hs . Index )
r . Get ( "/connections/datasources/:id" , middleware . CanAdminPlugins ( hs . Cfg ) , hs . Index )
r . Get ( "/connections/datasources/:id/page/:page" , middleware . CanAdminPlugins ( hs . Cfg ) , hs . Index )
// App Root Page
appPluginIDScope := pluginaccesscontrol . ScopeProvider . GetResourceScope ( ac . Parameter ( ":id" ) )
r . Get ( "/a/:id/*" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , appPluginIDScope ) ) , hs . Index )
r . Get ( "/a/:id" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , appPluginIDScope ) ) , hs . Index )
r . Get ( "/a/:id/*" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , appPluginIDScope ) ) , hs . Index )
r . Get ( "/a/:id" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , appPluginIDScope ) ) , hs . Index )
r . Get ( "/d/:uid/:slug" , reqSignedIn , redirectFromLegacyPanelEditURL , hs . Index )
r . Get ( "/d/:uid" , reqSignedIn , redirectFromLegacyPanelEditURL , hs . Index )
@ -165,12 +161,7 @@ func (hs *HTTPServer) registerRoutes() {
)
}
r . Get ( "/explore" , authorize ( func ( c * contextmodel . ReqContext ) {
if f , ok := reqSignedIn . ( func ( c * contextmodel . ReqContext ) ) ; ok {
f ( c )
}
ensureEditorOrViewerCanEdit ( c )
} , ac . EvalPermission ( ac . ActionDatasourcesExplore ) ) , hs . Index )
r . Get ( "/explore" , authorize ( ac . EvalPermission ( ac . ActionDatasourcesExplore ) ) , hs . Index )
r . Get ( "/playlists/" , reqSignedIn , hs . Index )
r . Get ( "/playlists/*" , reqSignedIn , hs . Index )
@ -220,7 +211,7 @@ func (hs *HTTPServer) registerRoutes() {
if hs . License . FeatureEnabled ( "saml" ) && hs . Features . IsEnabled ( featuremgmt . FlagAuthenticationConfigUI ) {
// TODO change the scope when we extend the auth UI to more providers
r . Get ( "/admin/authentication/" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionSettingsWrite , ac . ScopeSettingsSAML ) ) , hs . Index )
r . Get ( "/admin/authentication/" , authorize ( ac . EvalPermission ( ac . ActionSettingsWrite , ac . ScopeSettingsSAML ) ) , hs . Index )
}
// authed api
@ -260,40 +251,40 @@ func (hs *HTTPServer) registerRoutes() {
apiRoute . Group ( "/users" , func ( usersRoute routing . RouteRegister ) {
userIDScope := ac . Scope ( "global.users" , "id" , ac . Parameter ( ":id" ) )
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 ) )
usersRoute . Get ( "/:id" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserByID ) )
usersRoute . Get ( "/:id/teams" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserTeams ) )
usersRoute . Get ( "/:id/orgs" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserOrgList ) )
usersRoute . Get ( "/" , authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) , routing . Wrap ( hs . searchUsersService . SearchUsers ) )
usersRoute . Get ( "/search" , authorize ( ac . EvalPermission ( ac . ActionUsersRead ) ) , routing . Wrap ( hs . searchUsersService . SearchUsersWithPaging ) )
usersRoute . Get ( "/:id" , authorize ( ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserByID ) )
usersRoute . Get ( "/:id/teams" , authorize ( ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserTeams ) )
usersRoute . Get ( "/:id/orgs" , authorize ( ac . EvalPermission ( ac . ActionUsersRead , userIDScope ) ) , routing . Wrap ( hs . GetUserOrgList ) )
// query parameters /users/lookup?loginOrEmail=admin@example.com
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 ) )
usersRoute . Get ( "/lookup" , authorize ( ac . EvalPermission ( ac . ActionUsersRead , ac . ScopeGlobalUsersAll ) ) , routing . Wrap ( hs . GetUserByLoginOrEmail ) )
usersRoute . Put ( "/:id" , authorize ( ac . EvalPermission ( ac . ActionUsersWrite , userIDScope ) ) , routing . Wrap ( hs . UpdateUser ) )
usersRoute . Post ( "/:id/using/:orgId" , authorize ( ac . EvalPermission ( ac . ActionUsersWrite , userIDScope ) ) , routing . Wrap ( hs . UpdateUserActiveOrg ) )
} )
// team (admin permission required)
apiRoute . Group ( "/teams" , func ( teamsRoute routing . RouteRegister ) {
teamsRoute . Post ( "/" , authorize ( reqCanAccessTeams , ac . EvalPermission ( ac . ActionTeamsCreate ) ) , routing . Wrap ( hs . CreateTeam ) )
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 ) )
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 ) )
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 ) )
teamsRoute . Post ( "/" , authorize ( ac . EvalPermission ( ac . ActionTeamsCreate ) ) , routing . Wrap ( hs . CreateTeam ) )
teamsRoute . Put ( "/:teamId" , authorize ( ac . EvalPermission ( ac . ActionTeamsWrite , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . UpdateTeam ) )
teamsRoute . Delete ( "/:teamId" , authorize ( ac . EvalPermission ( ac . ActionTeamsDelete , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . DeleteTeamByID ) )
teamsRoute . Get ( "/:teamId/members" , authorize ( ac . EvalPermission ( ac . ActionTeamsPermissionsRead , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . GetTeamMembers ) )
teamsRoute . Post ( "/:teamId/members" , authorize ( ac . EvalPermission ( ac . ActionTeamsPermissionsWrite , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . AddTeamMember ) )
teamsRoute . Put ( "/:teamId/members/:userId" , authorize ( ac . EvalPermission ( ac . ActionTeamsPermissionsWrite , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . UpdateTeamMember ) )
teamsRoute . Delete ( "/:teamId/members/:userId" , authorize ( ac . EvalPermission ( ac . ActionTeamsPermissionsWrite , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . RemoveTeamMember ) )
teamsRoute . Get ( "/:teamId/preferences" , authorize ( ac . EvalPermission ( ac . ActionTeamsRead , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . GetTeamPreferences ) )
teamsRoute . Put ( "/:teamId/preferences" , authorize ( ac . EvalPermission ( ac . ActionTeamsWrite , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . UpdateTeamPreferences ) )
} )
// team without requirement of user to be org admin
apiRoute . Group ( "/teams" , func ( teamsRoute routing . RouteRegister ) {
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 ) )
teamsRoute . Get ( "/:teamId" , authorize ( ac . EvalPermission ( ac . ActionTeamsRead , ac . ScopeTeamsID ) ) , routing . Wrap ( hs . GetTeamByID ) )
teamsRoute . Get ( "/search" , authorize ( ac . EvalPermission ( ac . ActionTeamsRead ) ) , routing . Wrap ( hs . SearchTeams ) )
} )
// org information available to all users.
apiRoute . Group ( "/org" , func ( orgRoute routing . RouteRegister ) {
orgRoute . Get ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetCurrentOrg ) )
orgRoute . Get ( "/quotas" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionOrgsQuotasRead ) ) , routing . Wrap ( hs . GetCurrentOrgQuotas ) )
orgRoute . Get ( "/" , authorize ( ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetCurrentOrg ) )
orgRoute . Get ( "/quotas" , authorize ( ac . EvalPermission ( ac . ActionOrgsQuotasRead ) ) , routing . Wrap ( hs . GetCurrentOrgQuotas ) )
} )
if hs . Features . IsEnabled ( featuremgmt . FlagStorage ) {
@ -313,23 +304,23 @@ func (hs *HTTPServer) registerRoutes() {
// current org
apiRoute . Group ( "/org" , func ( orgRoute routing . RouteRegister ) {
userIDScope := ac . Scope ( "users" , "id" , ac . Parameter ( ":userId" ) )
orgRoute . Put ( "/" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateCurrentOrg ) )
orgRoute . Put ( "/address" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateCurrentOrgAddress ) )
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 ) )
orgRoute . Post ( "/users" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersAdd , ac . ScopeUsersAll ) ) , quota ( user . QuotaTargetSrv ) , quota ( org . QuotaTargetSrv ) , routing . Wrap ( hs . AddOrgUserToCurrentOrg ) )
orgRoute . Patch ( "/users/:userId" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersWrite , userIDScope ) ) , routing . Wrap ( hs . UpdateOrgUserForCurrentOrg ) )
orgRoute . Delete ( "/users/:userId" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersRemove , userIDScope ) ) , routing . Wrap ( hs . RemoveOrgUserForCurrentOrg ) )
orgRoute . Put ( "/" , authorize ( ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateCurrentOrg ) )
orgRoute . Put ( "/address" , authorize ( ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateCurrentOrgAddress ) )
orgRoute . Get ( "/users" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . GetOrgUsersForCurrentOrg ) )
orgRoute . Get ( "/users/search" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . SearchOrgUsersWithPaging ) )
orgRoute . Post ( "/users" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd , ac . ScopeUsersAll ) ) , quota ( user . QuotaTargetSrv ) , quota ( org . QuotaTargetSrv ) , routing . Wrap ( hs . AddOrgUserToCurrentOrg ) )
orgRoute . Patch ( "/users/:userId" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersWrite , userIDScope ) ) , routing . Wrap ( hs . UpdateOrgUserForCurrentOrg ) )
orgRoute . Delete ( "/users/:userId" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersRemove , userIDScope ) ) , routing . Wrap ( hs . RemoveOrgUserForCurrentOrg ) )
// invites
orgRoute . Get ( "/invites" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , routing . Wrap ( hs . GetPendingOrgInvites ) )
orgRoute . Post ( "/invites" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , quota ( user . QuotaTargetSrv ) , quota ( user . QuotaTargetSrv ) , routing . Wrap ( hs . AddOrgInvite ) )
orgRoute . Patch ( "/invites/:code/revoke" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , routing . Wrap ( hs . RevokeInvite ) )
orgRoute . Get ( "/invites" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , routing . Wrap ( hs . GetPendingOrgInvites ) )
orgRoute . Post ( "/invites" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , quota ( user . QuotaTargetSrv ) , quota ( user . QuotaTargetSrv ) , routing . Wrap ( hs . AddOrgInvite ) )
orgRoute . Patch ( "/invites/:code/revoke" , authorize ( ac . EvalPermission ( ac . ActionOrgUsersAdd ) ) , routing . Wrap ( hs . RevokeInvite ) )
// prefs
orgRoute . Get ( "/preferences" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgsPreferencesRead ) ) , routing . Wrap ( hs . GetOrgPreferences ) )
orgRoute . Put ( "/preferences" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) , routing . Wrap ( hs . UpdateOrgPreferences ) )
orgRoute . Patch ( "/preferences" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) , routing . Wrap ( hs . PatchOrgPreferences ) )
orgRoute . Get ( "/preferences" , authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesRead ) ) , routing . Wrap ( hs . GetOrgPreferences ) )
orgRoute . Put ( "/preferences" , authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) , routing . Wrap ( hs . UpdateOrgPreferences ) )
orgRoute . Patch ( "/preferences" , authorize ( ac . EvalPermission ( ac . ActionOrgsPreferencesWrite ) ) , routing . Wrap ( hs . PatchOrgPreferences ) )
} )
// current org without requirement of user to be org admin
@ -346,40 +337,40 @@ func (hs *HTTPServer) registerRoutes() {
ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ,
)
}
orgRoute . Get ( "/users/lookup" , authorize ( reqOrgAdminDashOrFolderAdminOrTeamAdmin , lookupEvaluator ( ) ) , routing . Wrap ( hs . GetOrgUsersForCurrentOrgLookup ) )
orgRoute . Get ( "/users/lookup" , authorize ( lookupEvaluator ( ) ) , routing . Wrap ( hs . GetOrgUsersForCurrentOrgLookup ) )
} )
// create new org
apiRoute . Post ( "/orgs" , authorizeInOrg ( reqSignedIn , ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsCreate ) ) , quota ( org . QuotaTargetSrv ) , routing . Wrap ( hs . CreateOrg ) )
apiRoute . Post ( "/orgs" , authorizeInOrg ( ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsCreate ) ) , quota ( org . QuotaTargetSrv ) , routing . Wrap ( hs . CreateOrg ) )
// search all orgs
apiRoute . Get ( "/orgs" , authorizeInOrg ( reqGrafanaAdmin , ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . SearchOrgs ) )
apiRoute . Get ( "/orgs" , authorizeInOrg ( ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . SearchOrgs ) )
// orgs (admin routes)
apiRoute . Group ( "/orgs/:orgId" , func ( orgsRoute routing . RouteRegister ) {
userIDScope := ac . Scope ( "users" , "id" , ac . Parameter ( ":userId" ) )
orgsRoute . Get ( "/" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetOrgByID ) )
orgsRoute . Put ( "/" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateOrg ) )
orgsRoute . Put ( "/address" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateOrgAddress ) )
orgsRoute . Delete ( "/" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsDelete ) ) , routing . Wrap ( hs . DeleteOrgByID ) )
orgsRoute . Get ( "/users" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . GetOrgUsers ) )
orgsRoute . Get ( "/users/search" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . SearchOrgUsers ) )
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 . ActionOrgUsersWrite , 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 ( ac . ActionOrgsQuotasRead ) ) , routing . Wrap ( hs . GetOrgQuotas ) )
orgsRoute . Put ( "/quotas/:target" , authorizeInOrg ( reqGrafanaAdmin , ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsQuotasWrite ) ) , routing . Wrap ( hs . UpdateOrgQuota ) )
orgsRoute . Get ( "/" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetOrgByID ) )
orgsRoute . Put ( "/" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateOrg ) )
orgsRoute . Put ( "/address" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsWrite ) ) , routing . Wrap ( hs . UpdateOrgAddress ) )
orgsRoute . Delete ( "/" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsDelete ) ) , routing . Wrap ( hs . DeleteOrgByID ) )
orgsRoute . Get ( "/users" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . GetOrgUsers ) )
orgsRoute . Get ( "/users/search" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersRead ) ) , routing . Wrap ( hs . SearchOrgUsers ) )
orgsRoute . Post ( "/users" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersAdd , ac . ScopeUsersAll ) ) , routing . Wrap ( hs . AddOrgUser ) )
orgsRoute . Patch ( "/users/:userId" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersWrite , userIDScope ) ) , routing . Wrap ( hs . UpdateOrgUser ) )
orgsRoute . Delete ( "/users/:userId" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgUsersRemove , userIDScope ) ) , routing . Wrap ( hs . RemoveOrgUser ) )
orgsRoute . Get ( "/quotas" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsQuotasRead ) ) , routing . Wrap ( hs . GetOrgQuotas ) )
orgsRoute . Put ( "/quotas/:target" , authorizeInOrg ( ac . UseOrgFromContextParams , ac . EvalPermission ( ac . ActionOrgsQuotasWrite ) ) , routing . Wrap ( hs . UpdateOrgQuota ) )
} )
// orgs (admin routes)
apiRoute . Get ( "/orgs/name/:name/" , authorizeInOrg ( reqGrafanaAdmin , ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetOrgByName ) )
apiRoute . Get ( "/orgs/name/:name/" , authorizeInOrg ( ac . UseGlobalOrg , ac . EvalPermission ( ac . ActionOrgsRead ) ) , routing . Wrap ( hs . GetOrgByName ) )
// auth api keys
apiRoute . Group ( "/auth/keys" , func ( keysRoute routing . RouteRegister ) {
apikeyIDScope := ac . Scope ( "apikeys" , "id" , ac . Parameter ( ":id" ) )
keysRoute . Get ( "/" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionAPIKeyRead ) ) , routing . Wrap ( hs . GetAPIKeys ) )
keysRoute . Post ( "/" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionAPIKeyCreate ) ) , quota ( string ( apikey . QuotaTargetSrv ) ) , routing . Wrap ( hs . AddAPIKey ) )
keysRoute . Delete ( "/:id" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionAPIKeyDelete , apikeyIDScope ) ) , routing . Wrap ( hs . DeleteAPIKey ) )
keysRoute . Get ( "/" , authorize ( ac . EvalPermission ( ac . ActionAPIKeyRead ) ) , routing . Wrap ( hs . GetAPIKeys ) )
keysRoute . Post ( "/" , authorize ( ac . EvalPermission ( ac . ActionAPIKeyCreate ) ) , quota ( string ( apikey . QuotaTargetSrv ) ) , routing . Wrap ( hs . AddAPIKey ) )
keysRoute . Delete ( "/:id" , authorize ( ac . EvalPermission ( ac . ActionAPIKeyDelete , apikeyIDScope ) ) , routing . Wrap ( hs . DeleteAPIKey ) )
} )
// Preferences
@ -392,17 +383,17 @@ func (hs *HTTPServer) registerRoutes() {
idScope := datasources . ScopeProvider . GetResourceScope ( ac . Parameter ( ":id" ) )
uidScope := datasources . ScopeProvider . GetResourceScopeUID ( ac . Parameter ( ":uid" ) )
nameScope := datasources . ScopeProvider . GetResourceScopeName ( ac . Parameter ( ":name" ) )
datasourceRoute . Get ( "/" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionRead ) ) , routing . Wrap ( hs . GetDataSources ) )
datasourceRoute . Post ( "/" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionCreate ) ) , quota ( string ( datasources . QuotaTargetSrv ) ) , routing . Wrap ( hs . AddDataSource ) )
datasourceRoute . Put ( "/:id" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionWrite , idScope ) ) , routing . Wrap ( hs . UpdateDataSourceByID ) )
datasourceRoute . Put ( "/uid/:uid" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionWrite , uidScope ) ) , routing . Wrap ( hs . UpdateDataSourceByUID ) )
datasourceRoute . Delete ( "/:id" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionDelete , idScope ) ) , routing . Wrap ( hs . DeleteDataSourceById ) )
datasourceRoute . Delete ( "/uid/:uid" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionDelete , uidScope ) ) , routing . Wrap ( hs . DeleteDataSourceByUID ) )
datasourceRoute . Delete ( "/name/:name" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionDelete , nameScope ) ) , routing . Wrap ( hs . DeleteDataSourceByName ) )
datasourceRoute . Get ( "/:id" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionRead , idScope ) ) , routing . Wrap ( hs . GetDataSourceById ) )
datasourceRoute . Get ( "/uid/:uid" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionRead , uidScope ) ) , routing . Wrap ( hs . GetDataSourceByUID ) )
datasourceRoute . Get ( "/name/:name" , authorize ( reqOrgAdmin , ac . EvalPermission ( datasources . ActionRead , nameScope ) ) , routing . Wrap ( hs . GetDataSourceByName ) )
datasourceRoute . Get ( "/id/:name" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionIDRead , nameScope ) ) , routing . Wrap ( hs . GetDataSourceIdByName ) )
datasourceRoute . Get ( "/" , authorize ( ac . EvalPermission ( datasources . ActionRead ) ) , routing . Wrap ( hs . GetDataSources ) )
datasourceRoute . Post ( "/" , authorize ( ac . EvalPermission ( datasources . ActionCreate ) ) , quota ( string ( datasources . QuotaTargetSrv ) ) , routing . Wrap ( hs . AddDataSource ) )
datasourceRoute . Put ( "/:id" , authorize ( ac . EvalPermission ( datasources . ActionWrite , idScope ) ) , routing . Wrap ( hs . UpdateDataSourceByID ) )
datasourceRoute . Put ( "/uid/:uid" , authorize ( ac . EvalPermission ( datasources . ActionWrite , uidScope ) ) , routing . Wrap ( hs . UpdateDataSourceByUID ) )
datasourceRoute . Delete ( "/:id" , authorize ( ac . EvalPermission ( datasources . ActionDelete , idScope ) ) , routing . Wrap ( hs . DeleteDataSourceById ) )
datasourceRoute . Delete ( "/uid/:uid" , authorize ( ac . EvalPermission ( datasources . ActionDelete , uidScope ) ) , routing . Wrap ( hs . DeleteDataSourceByUID ) )
datasourceRoute . Delete ( "/name/:name" , authorize ( ac . EvalPermission ( datasources . ActionDelete , nameScope ) ) , routing . Wrap ( hs . DeleteDataSourceByName ) )
datasourceRoute . Get ( "/:id" , authorize ( ac . EvalPermission ( datasources . ActionRead , idScope ) ) , routing . Wrap ( hs . GetDataSourceById ) )
datasourceRoute . Get ( "/uid/:uid" , authorize ( ac . EvalPermission ( datasources . ActionRead , uidScope ) ) , routing . Wrap ( hs . GetDataSourceByUID ) )
datasourceRoute . Get ( "/name/:name" , authorize ( ac . EvalPermission ( datasources . ActionRead , nameScope ) ) , routing . Wrap ( hs . GetDataSourceByName ) )
datasourceRoute . Get ( "/id/:name" , authorize ( ac . EvalPermission ( datasources . ActionIDRead , nameScope ) ) , routing . Wrap ( hs . GetDataSourceIdByName ) )
} )
pluginIDScope := pluginaccesscontrol . ScopeProvider . GetResourceScope ( ac . Parameter ( ":pluginId" ) )
@ -410,96 +401,96 @@ func (hs *HTTPServer) registerRoutes() {
apiRoute . Get ( "/plugins/:pluginId/settings" , routing . Wrap ( hs . GetPluginSettingByID ) ) // RBAC check performed in handler for App Plugins
apiRoute . Get ( "/plugins/:pluginId/markdown/:name" , routing . Wrap ( hs . GetPluginMarkdown ) )
apiRoute . Get ( "/plugins/:pluginId/health" , routing . Wrap ( hs . CheckHealth ) )
apiRoute . Any ( "/plugins/:pluginId/resources" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . CallResource )
apiRoute . Any ( "/plugins/:pluginId/resources/*" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . CallResource )
apiRoute . Any ( "/plugins/:pluginId/resources" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . CallResource )
apiRoute . Any ( "/plugins/:pluginId/resources/*" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . CallResource )
apiRoute . Get ( "/plugins/errors" , routing . Wrap ( hs . GetPluginErrorsList ) )
apiRoute . Any ( "/plugin-proxy/:pluginId/*" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . ProxyPluginRequest )
apiRoute . Any ( "/plugin-proxy/:pluginId" , authorize ( reqSignedIn , ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . ProxyPluginRequest )
apiRoute . Any ( "/plugin-proxy/:pluginId/*" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . ProxyPluginRequest )
apiRoute . Any ( "/plugin-proxy/:pluginId" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionAppAccess , pluginIDScope ) ) , hs . ProxyPluginRequest )
if hs . Cfg . PluginAdminEnabled && ! hs . Cfg . PluginAdminExternalManageEnabled {
apiRoute . Group ( "/plugins" , func ( pluginRoute routing . RouteRegister ) {
pluginRoute . Post ( "/:pluginId/install" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) , routing . Wrap ( hs . InstallPlugin ) )
pluginRoute . Post ( "/:pluginId/uninstall" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) , routing . Wrap ( hs . UninstallPlugin ) )
pluginRoute . Post ( "/:pluginId/install" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) , routing . Wrap ( hs . InstallPlugin ) )
pluginRoute . Post ( "/:pluginId/uninstall" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionInstall ) ) , routing . Wrap ( hs . UninstallPlugin ) )
} )
}
apiRoute . Group ( "/plugins" , func ( pluginRoute routing . RouteRegister ) {
pluginRoute . Get ( "/:pluginId/dashboards/" , reqOrgAdmin , routing . Wrap ( hs . GetPluginDashboards ) )
pluginRoute . Post ( "/:pluginId/settings" , authorize ( reqOrgAdmin , ac . EvalPermission ( pluginaccesscontrol . ActionWrite , pluginIDScope ) ) , routing . Wrap ( hs . UpdatePluginSetting ) )
pluginRoute . Post ( "/:pluginId/settings" , authorize ( ac . EvalPermission ( pluginaccesscontrol . ActionWrite , pluginIDScope ) ) , routing . Wrap ( hs . UpdatePluginSetting ) )
pluginRoute . Get ( "/:pluginId/metrics" , reqOrgAdmin , routing . Wrap ( hs . CollectPluginMetrics ) )
} )
apiRoute . Get ( "/frontend/settings/" , hs . GetFrontendSettings )
apiRoute . Any ( "/datasources/proxy/:id/*" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequest )
apiRoute . Any ( "/datasources/proxy/uid/:uid/*" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequestWithUID )
apiRoute . Any ( "/datasources/proxy/:id" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequest )
apiRoute . Any ( "/datasources/proxy/uid/:uid" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequestWithUID )
apiRoute . Any ( "/datasources/proxy/:id/*" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequest )
apiRoute . Any ( "/datasources/proxy/uid/:uid/*" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequestWithUID )
apiRoute . Any ( "/datasources/proxy/:id" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequest )
apiRoute . Any ( "/datasources/proxy/uid/:uid" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . ProxyDataSourceRequestWithUID )
// Deprecated: use /datasources/uid/:uid/resources API instead.
apiRoute . Any ( "/datasources/:id/resources" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResource )
apiRoute . Any ( "/datasources/uid/:uid/resources" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResourceWithUID )
apiRoute . Any ( "/datasources/:id/resources" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResource )
apiRoute . Any ( "/datasources/uid/:uid/resources" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResourceWithUID )
// Deprecated: use /datasources/uid/:uid/resources/* API instead.
apiRoute . Any ( "/datasources/:id/resources/*" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResource )
apiRoute . Any ( "/datasources/uid/:uid/resources/*" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResourceWithUID )
apiRoute . Any ( "/datasources/:id/resources/*" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResource )
apiRoute . Any ( "/datasources/uid/:uid/resources/*" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , hs . CallDatasourceResourceWithUID )
// Deprecated: use /datasources/uid/:uid/health API instead.
apiRoute . Any ( "/datasources/:id/health" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . CheckDatasourceHealth ) )
apiRoute . Any ( "/datasources/uid/:uid/health" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . CheckDatasourceHealthWithUID ) )
apiRoute . Any ( "/datasources/:id/health" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . CheckDatasourceHealth ) )
apiRoute . Any ( "/datasources/uid/:uid/health" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . CheckDatasourceHealthWithUID ) )
// Folders
apiRoute . Group ( "/folders" , func ( folderRoute routing . RouteRegister ) {
idScope := dashboards . ScopeFoldersProvider . GetResourceScope ( ac . Parameter ( ":id" ) )
uidScope := dashboards . ScopeFoldersProvider . GetResourceScopeUID ( ac . Parameter ( ":uid" ) )
folderRoute . Get ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersRead ) ) , routing . Wrap ( hs . GetFolders ) )
folderRoute . Get ( "/id/:id" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersRead , idScope ) ) , routing . Wrap ( hs . GetFolderByID ) )
folderRoute . Post ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersCreate ) ) , routing . Wrap ( hs . CreateFolder ) )
folderRoute . Get ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead ) ) , routing . Wrap ( hs . GetFolders ) )
folderRoute . Get ( "/id/:id" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead , idScope ) ) , routing . Wrap ( hs . GetFolderByID ) )
folderRoute . Post ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersCreate ) ) , routing . Wrap ( hs . CreateFolder ) )
folderRoute . Group ( "/:uid" , func ( folderUidRoute routing . RouteRegister ) {
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 . Post ( "/move" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersWrite , uidScope ) ) , routing . Wrap ( hs . MoveFolder ) )
folderUidRoute . Delete ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersDelete , uidScope ) ) , routing . Wrap ( hs . DeleteFolder ) )
folderUidRoute . Get ( "/counts" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionFoldersRead , uidScope ) ) , routing . Wrap ( hs . GetFolderDescendantCounts ) )
folderUidRoute . Get ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead , uidScope ) ) , routing . Wrap ( hs . GetFolderByUID ) )
folderUidRoute . Put ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersWrite , uidScope ) ) , routing . Wrap ( hs . UpdateFolder ) )
folderUidRoute . Post ( "/move" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersWrite , uidScope ) ) , routing . Wrap ( hs . MoveFolder ) )
folderUidRoute . Delete ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersDelete , uidScope ) ) , routing . Wrap ( hs . DeleteFolder ) )
folderUidRoute . Get ( "/counts" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersRead , uidScope ) ) , routing . Wrap ( hs . GetFolderDescendantCounts ) )
folderUidRoute . Group ( "/permissions" , func ( folderPermissionRoute routing . RouteRegister ) {
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 ) )
folderPermissionRoute . Get ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersPermissionsRead , uidScope ) ) , routing . Wrap ( hs . GetFolderPermissionList ) )
folderPermissionRoute . Post ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionFoldersPermissionsWrite , uidScope ) ) , routing . Wrap ( hs . UpdateFolderPermissions ) )
} )
} )
} )
// Dashboard
apiRoute . Group ( "/dashboards" , func ( dashboardRoute routing . RouteRegister ) {
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 ) )
dashboardRoute . Get ( "/uid/:uid" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsRead ) ) , routing . Wrap ( hs . GetDashboard ) )
dashboardRoute . Delete ( "/uid/:uid" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsDelete ) ) , routing . Wrap ( hs . DeleteDashboardByUID ) )
dashboardRoute . Group ( "/uid/:uid" , func ( dashUidRoute routing . RouteRegister ) {
dashUidRoute . Get ( "/versions" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersions ) )
dashUidRoute . Post ( "/restore" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . RestoreDashboardVersion ) )
dashUidRoute . Get ( "/versions/:id" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersion ) )
dashUidRoute . Get ( "/versions" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersions ) )
dashUidRoute . Post ( "/restore" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . RestoreDashboardVersion ) )
dashUidRoute . Get ( "/versions/:id" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersion ) )
dashUidRoute . Group ( "/permissions" , func ( dashboardPermissionRoute routing . RouteRegister ) {
dashboardPermissionRoute . Get ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) , routing . Wrap ( hs . GetDashboardPermissionList ) )
dashboardPermissionRoute . Post ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) , routing . Wrap ( hs . UpdateDashboardPermissions ) )
dashboardPermissionRoute . Get ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) , routing . Wrap ( hs . GetDashboardPermissionList ) )
dashboardPermissionRoute . Post ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) , routing . Wrap ( hs . UpdateDashboardPermissions ) )
} )
} )
dashboardRoute . Post ( "/calculate-diff" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . CalculateDashboardDiff ) )
dashboardRoute . Post ( "/validate" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . ValidateDashboard ) )
dashboardRoute . Post ( "/calculate-diff" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . CalculateDashboardDiff ) )
dashboardRoute . Post ( "/validate" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . ValidateDashboard ) )
dashboardRoute . Post ( "/trim" , routing . Wrap ( hs . TrimDashboard ) )
dashboardRoute . Post ( "/db" , authorize ( reqSignedIn , ac . EvalAny ( ac . EvalPermission ( dashboards . ActionDashboardsCreate ) , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ) , routing . Wrap ( hs . PostDashboard ) )
dashboardRoute . Post ( "/db" , authorize ( ac . EvalAny ( ac . EvalPermission ( dashboards . ActionDashboardsCreate ) , ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) ) , routing . Wrap ( hs . PostDashboard ) )
dashboardRoute . Get ( "/home" , routing . Wrap ( hs . GetHomeDashboard ) )
dashboardRoute . Get ( "/tags" , hs . GetDashboardTags )
// Deprecated: used to convert internal IDs to UIDs
dashboardRoute . Get ( "/ids/:ids" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsRead ) ) , hs . GetDashboardUIDs )
dashboardRoute . Get ( "/ids/:ids" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsRead ) ) , hs . GetDashboardUIDs )
// Deprecated: use /uid/:uid API instead.
dashboardRoute . Group ( "/id/:dashboardId" , func ( dashIdRoute routing . RouteRegister ) {
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 ) )
dashIdRoute . Get ( "/versions" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersions ) )
dashIdRoute . Get ( "/versions/:id" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . GetDashboardVersion ) )
dashIdRoute . Post ( "/restore" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsWrite ) ) , routing . Wrap ( hs . RestoreDashboardVersion ) )
dashIdRoute . Group ( "/permissions" , func ( dashboardPermissionRoute routing . RouteRegister ) {
dashboardPermissionRoute . Get ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) , routing . Wrap ( hs . GetDashboardPermissionList ) )
dashboardPermissionRoute . Post ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) , routing . Wrap ( hs . UpdateDashboardPermissions ) )
dashboardPermissionRoute . Get ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsRead ) ) , routing . Wrap ( hs . GetDashboardPermissionList ) )
dashboardPermissionRoute . Post ( "/" , authorize ( ac . EvalPermission ( dashboards . ActionDashboardsPermissionsWrite ) ) , routing . Wrap ( hs . UpdateDashboardPermissions ) )
} )
} )
} )
@ -526,7 +517,7 @@ func (hs *HTTPServer) registerRoutes() {
// metrics
// DataSource w/ expressions
apiRoute . Post ( "/ds/query" , authorize ( reqSignedIn , ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . QueryMetricsV2 ) )
apiRoute . Post ( "/ds/query" , authorize ( ac . EvalPermission ( datasources . ActionQuery ) ) , routing . Wrap ( hs . QueryMetricsV2 ) )
apiRoute . Group ( "/alerts" , func ( alertsRoute routing . RouteRegister ) {
alertsRoute . Post ( "/test" , routing . Wrap ( hs . AlertTest ) )
@ -564,17 +555,17 @@ func (hs *HTTPServer) registerRoutes() {
orgRoute . Get ( "/lookup" , routing . Wrap ( hs . GetAlertNotificationLookup ) )
} )
apiRoute . Get ( "/annotations" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionAnnotationsRead ) ) , routing . Wrap ( hs . GetAnnotations ) )
apiRoute . Post ( "/annotations/mass-delete" , authorize ( reqOrgAdmin , ac . EvalPermission ( ac . ActionAnnotationsDelete ) ) , routing . Wrap ( hs . MassDeleteAnnotations ) )
apiRoute . Get ( "/annotations" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead ) ) , routing . Wrap ( hs . GetAnnotations ) )
apiRoute . Post ( "/annotations/mass-delete" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsDelete ) ) , routing . Wrap ( hs . MassDeleteAnnotations ) )
apiRoute . Group ( "/annotations" , func ( annotationsRoute routing . RouteRegister ) {
annotationsRoute . Post ( "/" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionAnnotationsCreate ) ) , routing . Wrap ( hs . PostAnnotation ) )
annotationsRoute . Get ( "/:annotationId" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionAnnotationsRead , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . GetAnnotationByID ) )
annotationsRoute . Delete ( "/:annotationId" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionAnnotationsDelete , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . DeleteAnnotationByID ) )
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 ) )
annotationsRoute . Post ( "/graphite" , authorize ( reqEditorRole , ac . EvalPermission ( ac . ActionAnnotationsCreate , ac . ScopeAnnotationsTypeOrganization ) ) , routing . Wrap ( hs . PostGraphiteAnnotation ) )
annotationsRoute . Get ( "/tags" , authorize ( reqSignedIn , ac . EvalPermission ( ac . ActionAnnotationsRead ) ) , routing . Wrap ( hs . GetAnnotationTags ) )
annotationsRoute . Post ( "/" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsCreate ) ) , routing . Wrap ( hs . PostAnnotation ) )
annotationsRoute . Get ( "/:annotationId" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . GetAnnotationByID ) )
annotationsRoute . Delete ( "/:annotationId" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsDelete , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . DeleteAnnotationByID ) )
annotationsRoute . Put ( "/:annotationId" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsWrite , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . UpdateAnnotation ) )
annotationsRoute . Patch ( "/:annotationId" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsWrite , ac . ScopeAnnotationsID ) ) , routing . Wrap ( hs . PatchAnnotation ) )
annotationsRoute . Post ( "/graphite" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsCreate , ac . ScopeAnnotationsTypeOrganization ) ) , routing . Wrap ( hs . PostGraphiteAnnotation ) )
annotationsRoute . Get ( "/tags" , authorize ( ac . EvalPermission ( ac . ActionAnnotationsRead ) ) , routing . Wrap ( hs . GetAnnotationTags ) )
} )
apiRoute . Post ( "/frontend-metrics" , routing . Wrap ( hs . PostFrontendMetrics ) )
@ -600,9 +591,9 @@ func (hs *HTTPServer) registerRoutes() {
// admin api
r . Group ( "/api/admin" , func ( adminRoute routing . RouteRegister ) {
// There is additional filter which will ensure that user sees only settings that they are allowed to see, so we don't need provide additional scope here for ActionSettingsRead.
adminRoute . Get ( "/settings" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionSettingsRead ) ) , routing . Wrap ( hs . AdminGetSettings ) )
adminRoute . Get ( "/settings-verbose" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionSettingsRead ) ) , routing . Wrap ( hs . AdminGetVerboseSettings ) )
adminRoute . Get ( "/stats" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionServerStatsRead ) ) , routing . Wrap ( hs . AdminGetStats ) )
adminRoute . Get ( "/settings" , authorize ( ac . EvalPermission ( ac . ActionSettingsRead ) ) , routing . Wrap ( hs . AdminGetSettings ) )
adminRoute . Get ( "/settings-verbose" , authorize ( ac . EvalPermission ( ac . ActionSettingsRead ) ) , routing . Wrap ( hs . AdminGetVerboseSettings ) )
adminRoute . Get ( "/stats" , authorize ( ac . EvalPermission ( ac . ActionServerStatsRead ) ) , routing . Wrap ( hs . AdminGetStats ) )
adminRoute . Post ( "/pause-all-alerts" , reqGrafanaAdmin , routing . Wrap ( hs . PauseAllAlerts ( setting . AlertingEnabled ) ) )
adminRoute . Post ( "/encryption/rotate-data-keys" , reqGrafanaAdmin , routing . Wrap ( hs . AdminRotateDataEncryptionKeys ) )
@ -613,29 +604,29 @@ func (hs *HTTPServer) registerRoutes() {
adminRoute . Post ( "/encryption/migrate-secrets/from-plugin" , reqGrafanaAdmin , routing . Wrap ( hs . AdminMigrateSecretsFromPlugin ) )
adminRoute . Post ( "/encryption/delete-secretsmanagerplugin-secrets" , reqGrafanaAdmin , routing . Wrap ( hs . AdminDeleteAllSecretsManagerPluginSecrets ) )
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 ) )
adminRoute . Post ( "/provisioning/alerting/reload" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersAlertRules ) ) , routing . Wrap ( hs . AdminProvisioningReloadAlerting ) )
adminRoute . Post ( "/provisioning/dashboards/reload" , authorize ( ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersDashboards ) ) , routing . Wrap ( hs . AdminProvisioningReloadDashboards ) )
adminRoute . Post ( "/provisioning/plugins/reload" , authorize ( ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersPlugins ) ) , routing . Wrap ( hs . AdminProvisioningReloadPlugins ) )
adminRoute . Post ( "/provisioning/datasources/reload" , authorize ( ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersDatasources ) ) , routing . Wrap ( hs . AdminProvisioningReloadDatasources ) )
adminRoute . Post ( "/provisioning/notifications/reload" , authorize ( ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersNotifications ) ) , routing . Wrap ( hs . AdminProvisioningReloadNotifications ) )
adminRoute . Post ( "/provisioning/alerting/reload" , authorize ( ac . EvalPermission ( ActionProvisioningReload , ScopeProvisionersAlertRules ) ) , routing . Wrap ( hs . AdminProvisioningReloadAlerting ) )
} , reqSignedIn )
// Administering users
r . Group ( "/api/admin/users" , func ( adminUserRoute routing . RouteRegister ) {
userIDScope := ac . Scope ( "global.users" , "id" , ac . Parameter ( ":id" ) )
adminUserRoute . Post ( "/" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersCreate ) ) , routing . Wrap ( hs . AdminCreateUser ) )
adminUserRoute . Put ( "/:id/password" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersPasswordUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminUpdateUserPassword ) )
adminUserRoute . Put ( "/:id/permissions" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersPermissionsUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminUpdateUserPermissions ) )
adminUserRoute . Delete ( "/:id" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersDelete , userIDScope ) ) , routing . Wrap ( hs . AdminDeleteUser ) )
adminUserRoute . Post ( "/:id/disable" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersDisable , userIDScope ) ) , routing . Wrap ( hs . AdminDisableUser ) )
adminUserRoute . Post ( "/:id/enable" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersEnable , userIDScope ) ) , routing . Wrap ( hs . AdminEnableUser ) )
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 ) )
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 ) )
adminUserRoute . Post ( "/:id/revoke-auth-token" , authorize ( reqGrafanaAdmin , ac . EvalPermission ( ac . ActionUsersAuthTokenUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminRevokeUserAuthToken ) )
adminUserRoute . Post ( "/" , authorize ( ac . EvalPermission ( ac . ActionUsersCreate ) ) , routing . Wrap ( hs . AdminCreateUser ) )
adminUserRoute . Put ( "/:id/password" , authorize ( ac . EvalPermission ( ac . ActionUsersPasswordUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminUpdateUserPassword ) )
adminUserRoute . Put ( "/:id/permissions" , authorize ( ac . EvalPermission ( ac . ActionUsersPermissionsUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminUpdateUserPermissions ) )
adminUserRoute . Delete ( "/:id" , authorize ( ac . EvalPermission ( ac . ActionUsersDelete , userIDScope ) ) , routing . Wrap ( hs . AdminDeleteUser ) )
adminUserRoute . Post ( "/:id/disable" , authorize ( ac . EvalPermission ( ac . ActionUsersDisable , userIDScope ) ) , routing . Wrap ( hs . AdminDisableUser ) )
adminUserRoute . Post ( "/:id/enable" , authorize ( ac . EvalPermission ( ac . ActionUsersEnable , userIDScope ) ) , routing . Wrap ( hs . AdminEnableUser ) )
adminUserRoute . Get ( "/:id/quotas" , authorize ( ac . EvalPermission ( ac . ActionUsersQuotasList , userIDScope ) ) , routing . Wrap ( hs . GetUserQuotas ) )
adminUserRoute . Put ( "/:id/quotas/:target" , authorize ( ac . EvalPermission ( ac . ActionUsersQuotasUpdate , userIDScope ) ) , routing . Wrap ( hs . UpdateUserQuota ) )
adminUserRoute . Post ( "/:id/logout" , authorize ( ac . EvalPermission ( ac . ActionUsersLogout , userIDScope ) ) , routing . Wrap ( hs . AdminLogoutUser ) )
adminUserRoute . Get ( "/:id/auth-tokens" , authorize ( ac . EvalPermission ( ac . ActionUsersAuthTokenList , userIDScope ) ) , routing . Wrap ( hs . AdminGetUserAuthTokens ) )
adminUserRoute . Post ( "/:id/revoke-auth-token" , authorize ( ac . EvalPermission ( ac . ActionUsersAuthTokenUpdate , userIDScope ) ) , routing . Wrap ( hs . AdminRevokeUserAuthToken ) )
} , reqSignedIn )
// rendering