Hi Simon
I’m not sure if this is what is needed, but I have role synchronization configured this way:
- Create a mapper component (from the addon documentation)
@Component
public class SampleSynchronizingOidcUserMapper extends SynchronizingOidcUserMapper<User> {
public SampleSynchronizingOidcUserMapper(UnconstrainedDataManager dataManager,
UserRepository userRepository,
ClaimsRolesMapper claimsRolesMapper) {
super(dataManager, userRepository, claimsRolesMapper);
setSynchronizeRoleAssignments(true);
}
@Override
protected Class<User> getApplicationUserClass() {
return User.class;
}
@Override
protected void populateUserAttributes(OidcUser oidcUser, User jmixUser) {
jmixUser.setUsername(oidcUser.getPreferredUsername());
}
@Override
protected String getOidcUserUsername(OidcUser oidcUser) {
return oidcUser.getPreferredUsername();
}
}
- Add the property to application.properties
spring.security.oauth2.client.provider.keycloak.user-name-attribute=preferred_username
- Create a mapper in Keycloak (Client → Mappers)