diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java index 33ace78075..75e77f3c3a 100644 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java @@ -35,11 +35,6 @@ public abstract class AbstractLDAPFederationMapperFactory implements UserFederat public void postInit(KeycloakSessionFactory factory) { } - @Override - public List getConfigProperties() { - throw new IllegalStateException("Method not supported for this implementation"); - } - @Override public void close() { } diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapperFactory.java index d0d623005f..e26cd66ecf 100644 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapperFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/FullNameLDAPFederationMapperFactory.java @@ -46,7 +46,7 @@ public class FullNameLDAPFederationMapperFactory extends AbstractLDAPFederationM } @Override - public List getConfigProperties(RealmModel realm) { + public List getConfigProperties() { return configProperties; } diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/RoleLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/RoleLDAPFederationMapperFactory.java index a5eadd99a7..b02e2d3831 100644 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/RoleLDAPFederationMapperFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/RoleLDAPFederationMapperFactory.java @@ -59,7 +59,10 @@ public class RoleLDAPFederationMapperFactory extends AbstractLDAPFederationMappe "If true, then LDAP role mappings will be mapped to realm role mappings in Keycloak. Otherwise it will be mapped to client role mappings", ProviderConfigProperty.BOOLEAN_TYPE, "true"); configProperties.add(useRealmRolesMappings); - // NOTE: ClientID will be computed dynamically from available clients + ProviderConfigProperty clientIdProperty = createConfigProperty(RoleLDAPFederationMapper.CLIENT_ID, "Client ID", + "Client ID of client to which LDAP role mappings will be mapped. Applicable just if 'Use Realm Roles Mapping' is false", + ProviderConfigProperty.CLIENT_LIST_TYPE, null); + configProperties.add(clientIdProperty); } @Override @@ -78,18 +81,8 @@ public class RoleLDAPFederationMapperFactory extends AbstractLDAPFederationMappe } @Override - public List getConfigProperties(RealmModel realm) { - List props = new ArrayList(configProperties); - - Map clients = realm.getClientNameMap(); - List clientIds = new ArrayList(clients.keySet()); - - ProviderConfigProperty clientIdProperty = createConfigProperty(RoleLDAPFederationMapper.CLIENT_ID, "Client ID", - "Client ID of client to which LDAP role mappings will be mapped. Applicable just if 'Use Realm Roles Mapping' is false", - ProviderConfigProperty.LIST_TYPE, clientIds); - props.add(clientIdProperty); - - return props; + public List getConfigProperties() { + return configProperties; } @Override diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapperFactory.java index c0b9d79233..90dd21a8e4 100644 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapperFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/UserAttributeLDAPFederationMapperFactory.java @@ -48,7 +48,7 @@ public class UserAttributeLDAPFederationMapperFactory extends AbstractLDAPFedera } @Override - public List getConfigProperties(RealmModel realm) { + public List getConfigProperties() { return configProperties; } diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js index 7a0ae1a67e..cc3092fa1a 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -984,7 +984,10 @@ module.config([ '$routeProvider', function($routeProvider) { }, mapper : function(UserFederationMapperLoader) { return UserFederationMapperLoader(); - } + }, + clients : function(ClientListLoader) { + return ClientListLoader(); + }, }, controller : 'UserFederationMapperCtrl' }) @@ -1000,6 +1003,9 @@ module.config([ '$routeProvider', function($routeProvider) { mapperTypes : function(UserFederationMapperTypesLoader) { return UserFederationMapperTypesLoader(); }, + clients : function(ClientListLoader) { + return ClientListLoader(); + } }, controller : 'UserFederationMapperCreateCtrl' }) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js index bc723f31e5..cee2689a77 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js @@ -754,10 +754,11 @@ module.controller('UserFederationMapperListCtrl', function($scope, $location, No }); -module.controller('UserFederationMapperCtrl', function($scope, realm, provider, mapperTypes, mapper, UserFederationMapper, Notifications, Dialog, $location) { +module.controller('UserFederationMapperCtrl', function($scope, realm, provider, mapperTypes, mapper, clients, UserFederationMapper, Notifications, Dialog, $location) { console.log('UserFederationMapperCtrl'); $scope.realm = realm; $scope.provider = provider; + $scope.clients = clients; $scope.create = false; $scope.mapper = angular.copy(mapper); $scope.changed = false; @@ -780,10 +781,10 @@ module.controller('UserFederationMapperCtrl', function($scope, realm, provider, $location.url("/realms/" + realm.realm + '/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + mapper.id); Notifications.success("Your changes have been saved."); }, function(error) { - if (error.status == 400) { + if (error.status == 400 && error.data.error_description) { Notifications.error('Error in configuration of mapper: ' + error.data.error_description); } else { - Notification.error('Unexpected error when creating mapper'); + Notifications.error('Unexpected error when creating mapper'); } }); }; @@ -808,10 +809,11 @@ module.controller('UserFederationMapperCtrl', function($scope, realm, provider, }); -module.controller('UserFederationMapperCreateCtrl', function($scope, realm, provider, mapperTypes, UserFederationMapper, Notifications, Dialog, $location) { +module.controller('UserFederationMapperCreateCtrl', function($scope, realm, provider, mapperTypes, clients, UserFederationMapper, Notifications, Dialog, $location) { console.log('UserFederationMapperCreateCtrl'); $scope.realm = realm; $scope.provider = provider; + $scope.clients = clients; $scope.create = true; $scope.mapper = { federationProviderDisplayName: provider.displayName, config: {}}; $scope.mapperTypes = mapperTypes; @@ -844,10 +846,10 @@ module.controller('UserFederationMapperCreateCtrl', function($scope, realm, prov $location.url('/realms/' + realm.realm +'/user-federation/providers/' + provider.providerName + '/' + provider.id + '/mappers/' + id); Notifications.success("Mapper has been created."); }, function(error) { - if (error.status == 400) { + if (error.status == 400 && error.data.error_description) { Notifications.error('Error in configuration of mapper: ' + error.data.error_description); } else { - Notification.error('Unexpected error when creating mapper'); + Notifications.error('Unexpected error when creating mapper'); } }); }; diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/federated-mapper-detail.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/federated-mapper-detail.html index 0b9c144380..f06d032257 100644 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/federated-mapper-detail.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/federated-mapper-detail.html @@ -47,7 +47,7 @@
-
+
@@ -58,6 +58,11 @@
+
+ +
{{option.helpText}}
diff --git a/model/api/src/main/java/org/keycloak/mappers/UserFederationMapperFactory.java b/model/api/src/main/java/org/keycloak/mappers/UserFederationMapperFactory.java index 309036cb89..a4c877683e 100644 --- a/model/api/src/main/java/org/keycloak/mappers/UserFederationMapperFactory.java +++ b/model/api/src/main/java/org/keycloak/mappers/UserFederationMapperFactory.java @@ -31,6 +31,4 @@ public interface UserFederationMapperFactory extends ProviderFactory getConfigProperties(RealmModel realm); } diff --git a/model/api/src/main/java/org/keycloak/provider/ProviderConfigProperty.java b/model/api/src/main/java/org/keycloak/provider/ProviderConfigProperty.java index e3a217d1c6..fad9d6cf43 100755 --- a/model/api/src/main/java/org/keycloak/provider/ProviderConfigProperty.java +++ b/model/api/src/main/java/org/keycloak/provider/ProviderConfigProperty.java @@ -8,6 +8,7 @@ public class ProviderConfigProperty { public static final String BOOLEAN_TYPE="boolean"; public static final String STRING_TYPE="String"; public static final String LIST_TYPE="List"; + public static final String CLIENT_LIST_TYPE="ClientList"; protected String name; protected String label; diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java index e5deb3d382..b8216c4b41 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UserFederationProviderResource.java @@ -171,7 +171,7 @@ public class UserFederationProviderResource { rep.setCategory(mapperFactory.getDisplayCategory()); rep.setName(mapperFactory.getDisplayType()); rep.setHelpText(mapperFactory.getHelpText()); - List configProperties = mapperFactory.getConfigProperties(realm); + List configProperties = mapperFactory.getConfigProperties(); for (ProviderConfigProperty prop : configProperties) { ConfigPropertyRepresentation propRep = new ConfigPropertyRepresentation(); propRep.setName(prop.getName());