KEYCLOAK-10750 Check if role exist on get user/group in role endpoint

This commit is contained in:
Axel Messinese 2019-07-01 13:50:59 +02:00 committed by Marek Posolda
parent 0cdd23763c
commit b32d52e62b

View file

@ -397,6 +397,11 @@ public class RoleContainerResource extends RoleResource {
maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS;
RoleModel role = roleContainer.getRole(roleName);
if (role == null) {
throw new NotFoundException("Could not find role");
}
List<UserRepresentation> results = new ArrayList<UserRepresentation>();
List<UserModel> userModels = session.users().getRoleMembers(realm, role, firstResult, maxResults);
@ -431,6 +436,11 @@ public class RoleContainerResource extends RoleResource {
maxResults = maxResults != null ? maxResults : Constants.DEFAULT_MAX_RESULTS;
RoleModel role = roleContainer.getRole(roleName);
if (role == null) {
throw new NotFoundException("Could not find role");
}
List<GroupModel> groupsModel = session.realms().getGroupsByRole(realm, role, firstResult, maxResults);
return groupsModel.stream()