Access control: Allow users with permission to update team, dashboard and folder permissions to list users in OSS (#48275)
* Remove banner when missing permissions to list users * For OSS allow users to list other users if they have permissions to write either team, dashboard or folder permissions
This commit is contained in:
+13
-1
@@ -249,7 +249,19 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
|
||||
// current org without requirement of user to be org admin
|
||||
apiRoute.Group("/org", func(orgRoute routing.RouteRegister) {
|
||||
orgRoute.Get("/users/lookup", authorize(reqOrgAdminFolderAdminOrTeamAdmin, ac.EvalPermission(ac.ActionOrgUsersRead)), routing.Wrap(hs.GetOrgUsersForCurrentOrgLookup))
|
||||
lookupEvaluator := func() ac.Evaluator {
|
||||
if hs.Cfg.IsEnterprise {
|
||||
return ac.EvalPermission(ac.ActionOrgUsersRead)
|
||||
}
|
||||
// For oss we allow users with access to update permissions on either folders, teams or dashboards to perform the lookup
|
||||
return ac.EvalAny(
|
||||
ac.EvalPermission(ac.ActionOrgUsersRead),
|
||||
ac.EvalPermission(ac.ActionTeamsPermissionsWrite),
|
||||
ac.EvalPermission(dashboards.ActionDashboardsPermissionsWrite),
|
||||
ac.EvalPermission(dashboards.ActionFoldersPermissionsWrite),
|
||||
)
|
||||
}
|
||||
orgRoute.Get("/users/lookup", authorize(reqOrgAdminFolderAdminOrTeamAdmin, lookupEvaluator()), routing.Wrap(hs.GetOrgUsersForCurrentOrgLookup))
|
||||
})
|
||||
|
||||
// create new org
|
||||
|
||||
@@ -109,7 +109,7 @@ func (ss *SQLStore) GetOrgUsers(ctx context.Context, query *models.GetOrgUsersQu
|
||||
whereConditions = append(whereConditions, fmt.Sprintf("%s.is_service_account = ?", ss.Dialect.Quote("user")))
|
||||
whereParams = append(whereParams, ss.Dialect.BooleanStr(false))
|
||||
|
||||
if !accesscontrol.IsDisabled(ss.Cfg) && query.User != nil {
|
||||
if ss.Cfg.IsEnterprise && !accesscontrol.IsDisabled(ss.Cfg) && query.User != nil {
|
||||
acFilter, err := accesscontrol.Filter(query.User, "org_user.user_id", "users:id:", accesscontrol.ActionOrgUsersRead)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -62,6 +62,10 @@ func TestSQLStore_GetOrgUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
store := InitTestDB(t, InitTestDBOpt{FeatureFlags: []string{featuremgmt.FlagAccesscontrol}})
|
||||
store.Cfg.IsEnterprise = true
|
||||
defer func() {
|
||||
store.Cfg.IsEnterprise = false
|
||||
}()
|
||||
seedOrgUsers(t, store, 10)
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user