Access Control: Store permissions on SignedInUser (#43040)
* add permission structure to signedinuser * add middleware to load user permissions into signedinuser struct * apply LoadPermissionsMiddleware to http server * check for permissions in signedinuser struct Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Emil Tullstedt
parent
f1101efcec
commit
9558c09a7c
@@ -97,14 +97,10 @@ func BuildPermissionsMap(permissions []*Permission) map[string]bool {
|
||||
}
|
||||
|
||||
// GroupScopesByAction will group scopes on action
|
||||
func GroupScopesByAction(permissions []*Permission) map[string]map[string]struct{} {
|
||||
m := make(map[string]map[string]struct{})
|
||||
func GroupScopesByAction(permissions []*Permission) map[string][]string {
|
||||
m := make(map[string][]string)
|
||||
for _, p := range permissions {
|
||||
if _, ok := m[p.Action]; ok {
|
||||
m[p.Action][p.Scope] = struct{}{}
|
||||
} else {
|
||||
m[p.Action] = map[string]struct{}{p.Scope: {}}
|
||||
}
|
||||
m[p.Action] = append(m[p.Action], p.Scope)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user