Is there a setting avaiable to get an Admin API user search to return the Realm Roles?
This does not return the roles:
public List<UserRepresentation> getAllUsers() {
return keyCloak.realm( applicationSettings.getKeycloakApplicationProperties().getRealm()
)
.users().search( StringUtils.EMPTY, 0, Integer.MAX_VALUE );
}
If we need the roles, we are currently forced to this:
public UserRepresentation getUserById( String id ) {
UserResource userResource = keyCloak.realm(
applicationSettings.getKeycloakApplicationProperties().getRealm() )
.users().get( id );
UserRepresentation userRepresentation = userResource.toRepresentation();
userRepresentation.setRealmRoles(
userResource.roles().getAll().getRealmMappings().stream().map( RoleRepresentation::getName
).collect( Collectors.toList() ) );
userRepresentation.setGroups( userResource.groups().stream().map(
GroupRepresentation::getName ).collect( Collectors.toList() ) );
return userRepresentation;
}
There are some cases we have where we are getting a large list of users and would want to
exclude any R0LE_ADMIN in that list. Checking them all one-by-one would be very
inefficient.
--
Christopher Savory
Software Engineer | EdLogics