Tonyukuk
Tonyukuk

Reputation: 6195

How to get Composite Roles in KeyCloak

I am using keycloak-admin-client 11.0.3 in my Spring Boot Application. I am able to get all the roles from the KeyCloak. I made one role as a composite roles and assigned roles into that role.When I try to fetch that composite roles, it says role is composite but composite is null. Do you know the reason behind that ? You can find out my implementation and screenshot below.

   Keycloak keycloak = Keycloak.getInstance(
     "http://localhost:8080/auth",   
     "master",                       
     "admin",                        
     "admin",                       
     "admin-cli",                    
     "");       
                 
  List<RoleRepresentation> roleRepresentationList = keycloak.realm("master").roles().list();                                         
 for(RoleRepresentation roleRepresentation : roleRepresentationList) {                                                              
     System.out.println(roleRepresentation.getComposites());      

This is how I generated Sales Austria :

enter image description here

Upvotes: 2

Views: 2611

Answers (1)

dreamcrash
dreamcrash

Reputation: 51393

Instead of:

keycloak.realm("master").roles().list(); 
                      

use:

 keycloak.realm("master").toRepresentation().getRoles().getRealm();

Upvotes: 2

Related Questions