Commit db371d2a by Torkel Ödegaard

API: added admin role requirement for account changes, datasource admin, and api keys admin

parent 01cce09e
...@@ -14,6 +14,7 @@ func Register(r *macaron.Macaron) { ...@@ -14,6 +14,7 @@ func Register(r *macaron.Macaron) {
reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true}) reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true})
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true}) reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN) reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
reqAccountAdmin := middleware.RoleAuth(m.ROLE_ADMIN)
bind := binding.Bind bind := binding.Bind
// not logged in views // not logged in views
...@@ -55,7 +56,8 @@ func Register(r *macaron.Macaron) { ...@@ -55,7 +56,8 @@ func Register(r *macaron.Macaron) {
r.Post("/users", bind(m.AddAccountUserCommand{}), AddAccountUser) r.Post("/users", bind(m.AddAccountUserCommand{}), AddAccountUser)
r.Get("/users", GetAccountUsers) r.Get("/users", GetAccountUsers)
r.Delete("/users/:id", RemoveAccountUser) r.Delete("/users/:id", RemoveAccountUser)
}) }, reqAccountAdmin)
// Token // Token
r.Group("/tokens", func() { r.Group("/tokens", func() {
r.Combo("/"). r.Combo("/").
...@@ -63,20 +65,24 @@ func Register(r *macaron.Macaron) { ...@@ -63,20 +65,24 @@ func Register(r *macaron.Macaron) {
Post(bind(m.AddTokenCommand{}), AddToken). Post(bind(m.AddTokenCommand{}), AddToken).
Put(bind(m.UpdateTokenCommand{}), UpdateToken) Put(bind(m.UpdateTokenCommand{}), UpdateToken)
r.Delete("/:id", DeleteToken) r.Delete("/:id", DeleteToken)
}) }, reqAccountAdmin)
// Data sources // Data sources
r.Group("/datasources", func() { r.Group("/datasources", func() {
r.Combo("/").Get(GetDataSources).Put(AddDataSource).Post(UpdateDataSource) r.Combo("/").Get(GetDataSources).Put(AddDataSource).Post(UpdateDataSource)
r.Delete("/:id", DeleteDataSource) r.Delete("/:id", DeleteDataSource)
r.Any("/proxy/:id/*", reqSignedIn, ProxyDataSourceRequest) r.Any("/proxy/:id/*", reqSignedIn, ProxyDataSourceRequest)
}) }, reqAccountAdmin)
// Dashboard // Dashboard
r.Group("/dashboard", func() { r.Group("/dashboard", func() {
r.Combo("/:slug").Get(GetDashboard).Delete(DeleteDashboard) r.Combo("/:slug").Get(GetDashboard).Delete(DeleteDashboard)
r.Post("/", reqEditorRole, bind(m.SaveDashboardCommand{}), PostDashboard) r.Post("/", reqEditorRole, bind(m.SaveDashboardCommand{}), PostDashboard)
}) })
// Search // Search
r.Get("/search/", Search) r.Get("/search/", Search)
// metrics // metrics
r.Get("/metrics/test", GetTestMetrics) r.Get("/metrics/test", GetTestMetrics)
}, reqSignedIn) }, reqSignedIn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment