feat: add support for oauth whitelist file (#817)

This commit is contained in:
djedditt
2026-04-29 02:53:56 +02:00
parent d51e3efe32
commit 6b5a6bd982
7 changed files with 84 additions and 27 deletions
+3 -26
View File
@@ -34,32 +34,9 @@ func ParseUsers(usersStr []string, userAttributes map[string]config.UserAttribut
}
func GetUsers(usersCfg []string, usersPath string, userAttributes map[string]config.UserAttributes) ([]config.User, error) {
var usersStr []string
if len(usersCfg) == 0 && usersPath == "" {
return []config.User{}, nil
}
if len(usersCfg) > 0 {
usersStr = append(usersStr, usersCfg...)
}
if usersPath != "" {
contents, err := ReadFile(usersPath)
if err != nil {
return []config.User{}, err
}
lines := strings.SplitSeq(contents, "\n")
for line := range lines {
lineTrimmed := strings.TrimSpace(line)
if lineTrimmed == "" {
continue
}
usersStr = append(usersStr, lineTrimmed)
}
usersStr, err := GetStringList(usersCfg, usersPath)
if err != nil {
return []config.User{}, err
}
return ParseUsers(usersStr, userAttributes)