Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
db371d2a
Commit
db371d2a
authored
Jan 26, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: added admin role requirement for account changes, datasource admin, and api keys admin
parent
01cce09e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
pkg/api/api.go
+9
-3
No files found.
pkg/api/api.go
View file @
db371d2a
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment