Fix UserStorageManager.getGroupMembersStream potentially fetching all user (#33145)

Closes #32761
Signed-off-by: Benoit Messager <benoit.messager@liksi.fr>
Co-authored-by: Benoit Messager <benoit.messager@liksi.fr>
This commit is contained in:
Benoît 2024-09-24 09:51:35 +02:00 committed by GitHub
parent 3793d60104
commit bf19ec11cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View file

@ -439,7 +439,14 @@ public class UserStorageManager extends AbstractStorageManager<UserStorageProvid
map(id -> getUserById(realm, id)); map(id -> getUserById(realm, id));
} }
return Stream.empty(); return Stream.empty();
}, realm, firstResult, maxResults); },
(provider, firstResultInQuery, maxResultsInQuery) -> {
if (provider instanceof UserCountMethodsProvider) {
return ((UserCountMethodsProvider) provider).getUsersCount(realm, Set.of(group.getId()));
}
return 0;
},
realm, firstResult, maxResults);
return importValidation(realm, results); return importValidation(realm, results);
} }

View file

@ -43,6 +43,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -216,6 +217,11 @@ public class UserPropertyFileStorage implements UserLookupProvider, UserStorageP
return userPasswords.size(); return userPasswords.size();
} }
@Override
public int getUsersCount(RealmModel realm, Set<String> groupIds) {
return 0;
}
// @Override // @Override
// public Stream<UserModel> searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults) { // public Stream<UserModel> searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults) {
// addCall(SEARCH_METHOD, firstResult, maxResults); // addCall(SEARCH_METHOD, firstResult, maxResults);