[keycloak-user] Realm Roles not returned on search
Stian Thorgersen
sthorger at redhat.com
Fri Nov 4 01:28:05 EDT 2016
There's no way at the moment. You can open a JIRA for it.
On 2 November 2016 at 17:58, Chris Savory <chris.savory at edlogics.com> wrote:
> 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
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
More information about the keycloak-user
mailing list