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:
parent
3793d60104
commit
bf19ec11cf
2 changed files with 21 additions and 8 deletions
|
@ -431,15 +431,22 @@ public class UserStorageManager extends AbstractStorageManager<UserStorageProvid
|
||||||
@Override
|
@Override
|
||||||
public Stream<UserModel> getGroupMembersStream(final RealmModel realm, final GroupModel group, Integer firstResult, Integer maxResults) {
|
public Stream<UserModel> getGroupMembersStream(final RealmModel realm, final GroupModel group, Integer firstResult, Integer maxResults) {
|
||||||
Stream<UserModel> results = query((provider, firstResultInQuery, maxResultsInQuery) -> {
|
Stream<UserModel> results = query((provider, firstResultInQuery, maxResultsInQuery) -> {
|
||||||
if (provider instanceof UserQueryMethodsProvider) {
|
if (provider instanceof UserQueryMethodsProvider) {
|
||||||
return ((UserQueryMethodsProvider)provider).getGroupMembersStream(realm, group, firstResultInQuery, maxResultsInQuery);
|
return ((UserQueryMethodsProvider) provider).getGroupMembersStream(realm, group, firstResultInQuery, maxResultsInQuery);
|
||||||
|
|
||||||
} else if (provider instanceof UserFederatedStorageProvider) {
|
} else if (provider instanceof UserFederatedStorageProvider) {
|
||||||
return ((UserFederatedStorageProvider)provider).getMembershipStream(realm, group, firstResultInQuery, maxResultsInQuery).
|
return ((UserFederatedStorageProvider) provider).getMembershipStream(realm, group, firstResultInQuery, maxResultsInQuery).
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue