KEYCLOAK-10750 Check if role exist on get user/group in role endpoint
This commit is contained in:
parent
0cdd23763c
commit
b32d52e62b
1 changed files with 10 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue