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
782b5b6a
Commit
782b5b6a
authored
Mar 13, 2019
by
Hugo Häggmark
Committed by
Leonard Gram
Mar 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: viewers and editors can view teams
parent
c420af16
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
22 deletions
+15
-22
pkg/api/api.go
+4
-4
pkg/api/index.go
+1
-8
pkg/api/team.go
+5
-0
pkg/middleware/auth.go
+3
-8
public/app/routes/routes.ts
+2
-2
No files found.
pkg/api/api.go
View file @
782b5b6a
...
...
@@ -14,7 +14,7 @@ func (hs *HTTPServer) registerRoutes() {
reqGrafanaAdmin
:=
middleware
.
ReqGrafanaAdmin
reqEditorRole
:=
middleware
.
ReqEditorRole
reqOrgAdmin
:=
middleware
.
ReqOrgAdmin
reqAdminOr
EditorCanAdmin
:=
middleware
.
Edito
rCanAdmin
(
hs
.
Cfg
.
EditorsCanAdmin
)
reqAdminOr
CanAdmin
:=
middleware
.
AdminO
rCanAdmin
(
hs
.
Cfg
.
EditorsCanAdmin
)
redirectFromLegacyDashboardURL
:=
middleware
.
RedirectFromLegacyDashboardURL
()
redirectFromLegacyDashboardSoloURL
:=
middleware
.
RedirectFromLegacyDashboardSoloURL
()
quota
:=
middleware
.
Quota
(
hs
.
QuotaService
)
...
...
@@ -42,8 +42,8 @@ func (hs *HTTPServer) registerRoutes() {
r
.
Get
(
"/org/users"
,
reqOrgAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/users/new"
,
reqOrgAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/users/invite"
,
reqOrgAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/teams"
,
reqAdminOr
Editor
CanAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/teams/*"
,
reqAdminOr
Editor
CanAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/teams"
,
reqAdminOrCanAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/teams/*"
,
reqAdminOrCanAdmin
,
hs
.
Index
)
r
.
Get
(
"/org/apikeys/"
,
reqOrgAdmin
,
hs
.
Index
)
r
.
Get
(
"/dashboard/import/"
,
reqSignedIn
,
hs
.
Index
)
r
.
Get
(
"/configuration"
,
reqGrafanaAdmin
,
hs
.
Index
)
...
...
@@ -163,7 +163,7 @@ func (hs *HTTPServer) registerRoutes() {
teamsRoute
.
Delete
(
"/:teamId/members/:userId"
,
Wrap
(
hs
.
RemoveTeamMember
))
teamsRoute
.
Get
(
"/:teamId/preferences"
,
Wrap
(
GetTeamPreferences
))
teamsRoute
.
Put
(
"/:teamId/preferences"
,
bind
(
dtos
.
UpdatePrefsCmd
{}),
Wrap
(
UpdateTeamPreferences
))
},
reqAdminOr
Editor
CanAdmin
)
},
reqAdminOrCanAdmin
)
// team without requirement of user to be org admin
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
...
...
pkg/api/index.go
View file @
782b5b6a
...
...
@@ -327,7 +327,7 @@ func (hs *HTTPServer) setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, er
})
}
if
c
.
OrgRole
==
m
.
ROLE_EDITOR
&&
hs
.
Cfg
.
EditorsCanAdmin
{
if
(
c
.
OrgRole
==
m
.
ROLE_EDITOR
||
c
.
OrgRole
==
m
.
ROLE_VIEWER
)
&&
hs
.
Cfg
.
EditorsCanAdmin
{
cfgNode
:=
&
dtos
.
NavLink
{
Id
:
"cfg"
,
Text
:
"Configuration"
,
...
...
@@ -342,13 +342,6 @@ func (hs *HTTPServer) setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, er
Icon
:
"gicon gicon-team"
,
Url
:
setting
.
AppSubUrl
+
"/org/teams"
,
},
{
Text
:
"Plugins"
,
Id
:
"plugins"
,
Description
:
"View and configure plugins"
,
Icon
:
"gicon gicon-plugins"
,
Url
:
setting
.
AppSubUrl
+
"/plugins"
,
},
},
}
...
...
pkg/api/team.go
View file @
782b5b6a
...
...
@@ -11,6 +11,11 @@ import (
// POST /api/teams
func
(
hs
*
HTTPServer
)
CreateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
CreateTeamCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
if
c
.
OrgRole
==
m
.
ROLE_VIEWER
{
return
Error
(
403
,
"Not allowed to create team."
,
nil
)
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
==
m
.
ErrTeamNameTaken
{
return
Error
(
409
,
"Team name taken"
,
err
)
...
...
pkg/middleware/auth.go
View file @
782b5b6a
...
...
@@ -87,18 +87,13 @@ func Auth(options *AuthOptions) macaron.Handler {
}
}
func
Edito
rCanAdmin
(
enabled
bool
)
macaron
.
Handler
{
func
AdminO
rCanAdmin
(
enabled
bool
)
macaron
.
Handler
{
return
func
(
c
*
m
.
ReqContext
)
{
ok
:=
false
if
c
.
OrgRole
==
m
.
ROLE_ADMIN
{
ok
=
true
}
if
c
.
OrgRole
==
m
.
ROLE_EDITOR
&&
enabled
{
ok
=
true
return
}
if
!
ok
{
if
!
enabled
{
accessForbidden
(
c
)
}
}
...
...
public/app/routes/routes.ts
View file @
782b5b6a
...
...
@@ -195,7 +195,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
.
when
(
'/org/teams'
,
{
template
:
'<react-container />'
,
resolve
:
{
roles
:
()
=>
[
'Editor'
,
'Admin'
]
,
roles
:
()
=>
(
config
.
editorsCanAdmin
?
[]
:
[
'Editor'
,
'Admin'
])
,
component
:
()
=>
TeamList
,
},
})
...
...
@@ -207,7 +207,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
.
when
(
'/org/teams/edit/:id/:page?'
,
{
template
:
'<react-container />'
,
resolve
:
{
roles
:
()
=>
(
config
.
editorsCanAdmin
?
[
'Editor'
,
'Admin'
]
:
[
'Admin'
]),
roles
:
()
=>
(
config
.
editorsCanAdmin
?
[]
:
[
'Admin'
]),
component
:
()
=>
TeamPages
,
},
})
...
...
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