diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/GroupResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/GroupResource.java
index fa38c7cae0..db5b3a00ec 100755
--- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/GroupResource.java
+++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/GroupResource.java
@@ -79,6 +79,18 @@ public interface GroupResource {
@Path("role-mappings")
public RoleMappingResource roles();
+ /**
+ * Get users
+ *
+ * Returns a list of all users in group.
+ *
+ * @return Returns a max size of 100 users
+ */
+ @GET
+ @NoCache
+ @Path("/members")
+ @Produces(MediaType.APPLICATION_JSON)
+ public List members();
/**
* Get users
*
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java
index 2d5476b613..ea423352e9 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/GroupResource.java
@@ -212,7 +212,7 @@ public class GroupResource {
throw new NotFoundException("Could not find group by id");
}
- firstResult = firstResult != null ? firstResult : -1;
+ firstResult = firstResult != null ? firstResult : 0;
maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS;
List results = new ArrayList();
diff --git a/services/src/main/java/org/keycloak/storage/UserStorageManager.java b/services/src/main/java/org/keycloak/storage/UserStorageManager.java
index e1a269c65d..ae4cd128c0 100755
--- a/services/src/main/java/org/keycloak/storage/UserStorageManager.java
+++ b/services/src/main/java/org/keycloak/storage/UserStorageManager.java
@@ -379,6 +379,8 @@ public class UserStorageManager implements UserProvider, OnUserCache {
protected List query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) {
if (maxResults == 0) return Collections.EMPTY_LIST;
+ if (firstResult < 0) firstResult = 0;
+ if (maxResults < 0) maxResults = Integer.MAX_VALUE - 1;
List storageProviders = getStorageProviders(session, realm, UserQueryProvider.class);
// we can skip rest of method if there are no storage providers
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java
index d16626f86a..91d299f138 100755
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/group/GroupTest.java
@@ -602,7 +602,9 @@ public class GroupTest extends AbstractGroupTest {
}
assertEquals(100, group.members(null, null).size());
+ assertEquals(100, group.members().size());
assertEquals(105, group.members(0, 105).size());
assertEquals(110, group.members(0, 1000).size());
+ assertEquals(110, group.members(-1, -2).size());
}
}