From 5eb9291f3703023feeebe158f0846a264a555935 Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Wed, 27 Mar 2019 19:26:03 +0100 Subject: [PATCH] KEYCLOAK-9574 Fix broken Role Selection for LDAP Mapper in Admin-Console (#5883) We now wrap the result of a role-selection in an JS array and use the config value as is for rendering, instead of extracting the first component (which was the first char, since the value is a string). Previously any mapper that used role selection could not be used due to `LDAPMapperCreateCtrl` generating invalid config structures. Since the component configuration is represented via org.keycloak.representations.idm.ComponentRepresentation whose `config` property is a `MultivaluedHashMap` config values needs to be passed as an Array. However the LDAPMapperCreateCtrl in (users.js) only passed the role as a String. Signed-off-by: Thomas Darimont --- .../theme/base/admin/resources/js/controllers/users.js | 4 ++++ .../base/admin/resources/templates/kc-component-config.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js index ea95366b2d7b..820929b0361f 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js @@ -1690,6 +1690,10 @@ module.controller('LDAPMapperCreateCtrl', function($scope, realm, provider, mapp $scope.mapper.providerType = 'org.keycloak.storage.ldap.mappers.LDAPStorageMapper'; $scope.mapper.parentId = provider.id; + if ($scope.mapper.config && $scope.mapper.config["role"] && !Array.isArray($scope.mapper.config["role"])) { + $scope.mapper.config["role"] = [$scope.mapper.config["role"]]; + } + Components.save({realm: realm.realm}, $scope.mapper, function (data, headers) { var l = headers().location; var id = l.substring(l.lastIndexOf("/") + 1); diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html index 0f9903801430..ff73519006f1 100755 --- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html +++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html @@ -22,7 +22,7 @@
- +