Add an option to hide certain users in the UI (#28942)
* Add an option to hide certain users in the UI * revert changes for admin users routes * fix sqlstore function name * Improve slice management Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> * Hidden users: convert slice to map * filter with user logins instead of IDs * put HiddenUsers in Cfg struct * hide hidden users from dashboards/folders permissions list * Update conf/defaults.ini Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * fix params order * fix tests * fix dashboard/folder update with hidden user * add team tests * add dashboard and folder permissions tests * fixes after merge * fix tests * API: add test for org users endpoints * update hidden users management for dashboard / folder permissions * improve dashboard / folder permissions tests * fixes after merge * Guardian: add hidden acl tests * API: add team members tests * fix team sql syntax for postgres * api tests update * fix linter error * fix tests errors after merge Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com> Co-authored-by: Leonard Gram <leo@xlson.com>
This commit is contained in:
co-authored by
Emil Tullstedt
Torkel Ödegaard
Leonard Gram
parent
4c47fc56bb
commit
22788d1d86
@@ -308,6 +308,7 @@ type Cfg struct {
|
||||
|
||||
// User
|
||||
UserInviteMaxLifetime time.Duration
|
||||
HiddenUsers map[string]struct{}
|
||||
|
||||
// Annotations
|
||||
AlertingAnnotationCleanupSetting AnnotationCleanupSettings
|
||||
@@ -1118,6 +1119,13 @@ func readUserSettings(iniFile *ini.File, cfg *Cfg) error {
|
||||
return errors.New("the minimum supported value for the `user_invite_max_lifetime_duration` configuration is 15m (15 minutes)")
|
||||
}
|
||||
|
||||
cfg.HiddenUsers = make(map[string]struct{})
|
||||
hiddenUsers := users.Key("hidden_users").MustString("")
|
||||
for _, user := range strings.Split(hiddenUsers, ",") {
|
||||
user = strings.TrimSpace(user)
|
||||
cfg.HiddenUsers[user] = struct{}{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user