mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
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
@@ -64,12 +64,19 @@ func (ac *OSSAccessControlService) Evaluate(ctx context.Context, user *models.Si
|
||||
defer timer.ObserveDuration()
|
||||
metrics.MAccessEvaluationCount.Inc()
|
||||
|
||||
permissions, err := ac.GetUserPermissions(ctx, user)
|
||||
if err != nil {
|
||||
return false, err
|
||||
if user.Permissions == nil {
|
||||
user.Permissions = map[int64]map[string][]string{}
|
||||
}
|
||||
|
||||
return evaluator.Evaluate(accesscontrol.GroupScopesByAction(permissions))
|
||||
if _, ok := user.Permissions[user.OrgId]; !ok {
|
||||
permissions, err := ac.GetUserPermissions(ctx, user)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
user.Permissions[user.OrgId] = accesscontrol.GroupScopesByAction(permissions)
|
||||
}
|
||||
|
||||
return evaluator.Evaluate(user.Permissions[user.OrgId])
|
||||
}
|
||||
|
||||
// GetUserRoles returns user permissions based on built-in roles
|
||||
|
||||
Reference in New Issue
Block a user